<?php
// Wiki pública de Waterborne: docs + descarga (free) + reseñas (visibles sin login).
require_once __DIR__ . '/../includes/init.php';
require_once __DIR__ . '/../includes/plugins.php';
$slug = 'waterborne';
$loggedIn = is_logged_in();
$revTotal = 0; $revAvg = 0.0; $revList = []; $myRev = null; $revMsg = ''; $replies = [];

function wiki_pdo() {
    return new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4', DB_USER, DB_PASS,
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]);
}
function rw_stars($n) { $n = max(0, min(5, (int)$n)); return str_repeat('★', $n) . '<span class="off">' . str_repeat('★', 5 - $n) . '</span>'; }

if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['do'] ?? '') === 'review' && $loggedIn) {
    csrf_check();
    $rating = (int)($_POST['rating'] ?? 0); $comment = trim($_POST['comment'] ?? '');
    if ($rating >= 1 && $rating <= 5 && $comment !== '') {
        try {
            $pdo = wiki_pdo();
            $o = $pdo->prepare("SELECT 1 FROM licenses WHERE user_id=? AND plugin_slug=? AND status='active' LIMIT 1");
            $o->execute([$_SESSION['uid'], $slug]); $owns = $o->fetchColumn() ? 1 : 0;
            $pdo->prepare("INSERT INTO reviews (user_id, plugin_slug, rating, comment, verified_buyer) VALUES (?,?,?,?,?)
                ON DUPLICATE KEY UPDATE rating=VALUES(rating), comment=VALUES(comment), verified_buyer=VALUES(verified_buyer), created_at=NOW()")
                ->execute([$_SESSION['uid'], $slug, $rating, $comment, $owns]);
            header('Location: ./?saved=1'); exit;
        } catch (Throwable $e) { $revMsg = 'No se pudo guardar tu reseña.'; }
    } else { $revMsg = 'Elige estrellas y escribe un comentario.'; }
}
try {
    $pdo = wiki_pdo();
    $s = $pdo->prepare("SELECT COUNT(*) c, COALESCE(AVG(rating),0) a FROM reviews WHERE plugin_slug=? AND status='visible'");
    $s->execute([$slug]); $sm = $s->fetch();
    $revTotal = (int)$sm['c']; $revAvg = round((float)$sm['a'], 1);
    $s = $pdo->prepare("SELECT r.id, r.rating, r.comment, r.created_at, us.username, us.role,
        (SELECT GROUP_CONCAT(l.plugin_slug) FROM licenses l WHERE l.user_id=r.user_id AND l.status='active') owned
        FROM reviews r JOIN users us ON us.id=r.user_id
        WHERE r.plugin_slug=? AND r.status='visible' ORDER BY r.created_at DESC LIMIT 100");
    $s->execute([$slug]); $revList = $s->fetchAll();
    try {
        $rp = $pdo->prepare("SELECT id, admin_reply, admin_reply_at FROM reviews WHERE plugin_slug=? AND admin_reply IS NOT NULL AND admin_reply<>''");
        $rp->execute([$slug]);
        foreach ($rp->fetchAll() as $x) { $replies[(int)$x['id']] = $x; }
    } catch (Throwable $e) {}
    if ($loggedIn) {
        $m = $pdo->prepare("SELECT rating, comment FROM reviews WHERE user_id=? AND plugin_slug=?");
        $m->execute([$_SESSION['uid'], $slug]); $myRev = $m->fetch() ?: null;
    }
} catch (Throwable $e) {}
$DL = e(BASE) . '/waterborne/descargas/Waterborne-1.0.jar';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Waterborne — Thirst &amp; Waterborne Parasites for Minecraft | infinity3113</title>
<meta name="description" content="Waterborne: a hardcore thirst and waterborne-parasites system for Minecraft. Dirty water quenches your thirst but can infect you with parasites; craft cures and purified water. No required dependencies.">
<meta property="og:title" content="Waterborne — Thirst &amp; Parasites for Minecraft">
<meta property="og:description" content="Hardcore thirst + waterborne parasites. Every drop keeps you alive — or crawling with parasites. Runs standalone.">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>%F0%9F%92%A7</text></svg>">
<link rel="stylesheet" href="../assets/app.css">
</head>
<body>
<style>
  #crhub{
    --bg:#081016; --bg2:#0a1620; --panel:#0f1e2a; --panel2:#132635;
    --line:rgba(255,255,255,.09); --line2:rgba(255,255,255,.14);
    --gold:#f6c453; --gold-deep:#e0a92e; --green:#34d2f2; --teal:#7fe0ff; --purple:#6ec6ff;
    --text:#eaf6fb; --muted:#9fb8c4; --muted2:#6f8895; --maxw:1200px;
    --sans:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
    --mono:ui-monospace,"SF Mono","Cascadia Code",Consolas,monospace;
    background:
      radial-gradient(1100px 600px at 82% -10%, rgba(52,210,242,.16), transparent 60%),
      radial-gradient(900px 520px at 4% 2%, rgba(110,198,255,.10), transparent 55%),
      linear-gradient(180deg,var(--bg2),var(--bg) 42%);
    color:var(--text);font-family:var(--sans);font-size:16px;line-height:1.62;min-height:100vh;overflow-x:hidden;
  }
  #crhub *{box-sizing:border-box}
  #crhub a{color:inherit;text-decoration:none}
  #crhub h1,#crhub h2,#crhub h3{line-height:1.12;margin:0;letter-spacing:-.02em}
  #crhub .eyebrow{font:600 12px/1 var(--mono);letter-spacing:.22em;text-transform:uppercase;color:var(--green)}
  #crhub .top{position:sticky;top:0;z-index:50;backdrop-filter:blur(14px);background:rgba(8,16,22,.8);border-bottom:1px solid var(--line)}
  #crhub .top .in{max-width:var(--maxw);margin:0 auto;padding:0 22px;display:flex;align-items:center;gap:14px;height:62px;flex-wrap:wrap}
  #crhub .brand{display:flex;align-items:center;gap:11px;margin-right:auto}
  #crhub .brand .logo{width:38px;height:38px;border-radius:10px;flex:none;background:linear-gradient(145deg,var(--green),#1f8fc0);display:grid;place-items:center;font-size:20px;box-shadow:0 6px 20px rgba(52,210,242,.35)}
  #crhub .brand b{font-size:15px;font-weight:800;display:block}
  #crhub .brand span{font:600 11px/1.3 var(--mono);color:var(--muted);letter-spacing:.06em}
  #crhub .navlink{font-size:13.5px;font-weight:700;color:var(--muted);padding:8px 10px;border-radius:9px}
  #crhub .navlink:hover{color:var(--text);background:var(--panel)}
  #crhub .langsw{display:flex;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:3px}
  #crhub .langsw button{border:0;background:transparent;color:var(--muted);font-family:var(--mono);font-size:12px;font-weight:600;padding:6px 9px;border-radius:7px;cursor:pointer}
  #crhub .langsw button:hover{color:var(--text)}
  #crhub .langsw button.on{background:linear-gradient(145deg,var(--green),#1f8fc0);color:#03151d}
  #crhub .layout{max-width:var(--maxw);margin:0 auto;padding:24px 22px 0;display:grid;grid-template-columns:246px minmax(0,1fr);gap:34px;align-items:start}
  #crhub .side{position:sticky;top:86px}
  #crhub .plugsel{display:flex;align-items:center;gap:10px;padding:12px 13px;border-radius:13px;margin-bottom:8px;border:1px solid var(--green);background:linear-gradient(180deg,rgba(52,210,242,.1),var(--panel))}
  #crhub .plugsel .ic{font-size:20px}
  #crhub .plugsel b{font-size:14.5px;font-weight:800;display:block}
  #crhub .plugsel small{font:600 10px/1.3 var(--mono);color:var(--muted2);letter-spacing:.08em}
  #crhub .sidelabel{font:600 10px/1 var(--mono);letter-spacing:.18em;text-transform:uppercase;color:var(--muted2);padding:14px 12px 8px}
  #crhub .sidenav{display:flex;flex-direction:column;gap:2px}
  #crhub .sidenav a{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:9px;font-size:14px;font-weight:600;color:var(--muted);cursor:pointer;border-left:2px solid transparent}
  #crhub .sidenav a .n{width:19px;text-align:center;opacity:.85}
  #crhub .sidenav a:hover{color:var(--text);background:var(--panel)}
  #crhub .sidenav a.on{color:var(--text);background:var(--panel);border-left-color:var(--green)}
  #crhub .content{min-width:0;padding-bottom:40px}
  #crhub .page{display:none}
  #crhub .page.active{display:block;animation:crfade .25s ease}
  @keyframes crfade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
  #crhub .crumb{font:600 12px/1 var(--mono);letter-spacing:.05em;color:var(--muted2);margin-bottom:14px}
  #crhub .crumb b{color:var(--green)}
  #crhub .ptitle{font-size:clamp(26px,4vw,36px);font-weight:800;margin-bottom:10px}
  #crhub .plead{color:var(--muted);font-size:16.5px;max-width:64ch;margin-bottom:24px}
  #crhub h3.sub{font-size:19px;font-weight:800;margin:32px 0 14px}
  #crhub .hero{display:grid;grid-template-columns:1.05fr .95fr;gap:34px;align-items:center;margin-bottom:14px}
  #crhub .badge{display:inline-flex;align-items:center;gap:8px;padding:7px 13px;border-radius:999px;background:var(--panel);border:1px solid var(--line2);font:600 12.5px/1 var(--sans);color:var(--muted);margin-bottom:20px}
  #crhub .badge .dot{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 10px var(--green)}
  #crhub .hero h1{font-size:clamp(40px,6vw,66px);font-weight:900}
  #crhub .hero h1 .grad{background:linear-gradient(120deg,#fff 8%,var(--green) 52%,var(--teal));-webkit-background-clip:text;background-clip:text;color:transparent}
  #crhub .lede{color:var(--muted);font-size:clamp(15px,2vw,18px);margin:18px 0 26px;max-width:42ch}
  #crhub .cta{display:flex;gap:12px;flex-wrap:wrap}
  #crhub .btn{display:inline-flex;align-items:center;gap:9px;padding:12px 20px;border-radius:12px;font-weight:700;font-size:15px;cursor:pointer;border:1px solid transparent;transition:.18s}
  #crhub .btn.primary{background:linear-gradient(145deg,var(--green),#1f8fc0);color:#03151d;box-shadow:0 10px 26px rgba(52,210,242,.32)}
  #crhub .btn.primary:hover{transform:translateY(-2px)}
  #crhub .btn.ghost{background:var(--panel);border-color:var(--line2);color:var(--text)}
  #crhub .btn.ghost:hover{border-color:var(--green);color:var(--green)}
  #crhub .stats{display:flex;gap:24px;margin-top:30px;flex-wrap:wrap}
  #crhub .stats .s b{font-size:18px;font-weight:800;display:block}
  #crhub .stats .s span{font:600 10px/1 var(--mono);letter-spacing:.14em;text-transform:uppercase;color:var(--muted2)}
  #crhub .scroll{position:relative;justify-self:center;width:min(100%,380px);background:linear-gradient(180deg,var(--panel2),var(--panel));border:1px solid var(--line2);border-radius:22px;padding:22px}
  #crhub .scroll .mrow{display:flex;align-items:center;gap:10px;padding:11px 12px;border-radius:12px;background:#0a1620;border:1px solid var(--line);margin-bottom:9px}
  #crhub .scroll .mrow .e{font-size:20px}
  #crhub .scroll .mrow b{font-size:13.5px;font-weight:800;display:block}
  #crhub .scroll .mrow small{font:600 11px/1.2 var(--mono);color:var(--muted2)}
  #crhub .scroll .mrow .rr{margin-left:auto;font:800 11px/1 var(--mono);color:var(--gold)}
  #crhub .cards{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-top:20px}
  #crhub .card{background:linear-gradient(180deg,var(--panel),rgba(15,30,42,.55));border:1px solid var(--line);border-radius:16px;padding:18px;transition:.2s}
  #crhub .card:hover{border-color:var(--line2);transform:translateY(-3px)}
  #crhub .card .ico{width:42px;height:42px;border-radius:11px;display:grid;place-items:center;font-size:21px;margin-bottom:12px;background:var(--panel2);border:1px solid var(--line2)}
  #crhub .card h3{font-size:16px;font-weight:800}
  #crhub .card p{color:var(--muted);font-size:13.5px;margin:7px 0 0}
  #crhub .tablewrap{overflow-x:auto;border:1px solid var(--line);border-radius:14px;background:var(--panel);margin-top:8px}
  #crhub table{width:100%;border-collapse:collapse;min-width:480px}
  #crhub th,#crhub td{text-align:left;padding:12px 15px;border-bottom:1px solid var(--line);font-size:14px;vertical-align:top}
  #crhub th{font:600 11px/1 var(--mono);letter-spacing:.13em;text-transform:uppercase;color:var(--muted2)}
  #crhub tr:last-child td{border-bottom:0}
  #crhub code{font-family:var(--mono);font-size:12.5px;background:rgba(52,210,242,.12);color:var(--green);padding:3px 7px;border-radius:6px;white-space:nowrap}
  #crhub .perm{font-family:var(--mono);font-size:12px;color:var(--teal);white-space:nowrap}
  #crhub pre{background:#06121a;border:1px solid var(--line);border-radius:12px;padding:16px 18px;overflow-x:auto;margin:14px 0}
  #crhub pre code{background:none;color:#cfeefb;padding:0;white-space:pre;font-size:13px;line-height:1.7}
  #crhub .cmt{color:#5f7f8c}
  #crhub .note{margin-top:18px;padding:15px 17px;border-radius:12px;background:rgba(52,210,242,.08);border:1px solid rgba(52,210,242,.25);color:var(--muted);font-size:14px;display:flex;gap:11px}
  #crhub .note b{color:var(--text)}
  #crhub ol.steps{counter-reset:s;list-style:none;padding:0;margin:8px 0 0}
  #crhub ol.steps li{position:relative;padding:12px 0 12px 44px;border-bottom:1px solid var(--line);color:var(--muted);font-size:14.5px}
  #crhub ol.steps li:last-child{border-bottom:0}
  #crhub ol.steps li::before{counter-increment:s;content:counter(s);position:absolute;left:0;top:10px;width:30px;height:30px;border-radius:9px;background:var(--panel2);border:1px solid var(--line2);color:var(--green);font:800 13px/30px var(--mono);text-align:center}
  #crhub ol.steps b{color:var(--text)}
  #crhub .rev-head{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-bottom:18px}
  #crhub .rev-avg{font-size:40px;font-weight:900}
  #crhub .rev-st{color:var(--gold);letter-spacing:2px} #crhub .off{color:#39505c}
  #crhub .rev-form{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:18px;margin-bottom:16px}
  #crhub .starpick{display:flex;gap:6px;font-size:28px;color:#39505c;cursor:pointer}
  #crhub .starpick span.hot{color:var(--gold)}
  #crhub .rev-ta{width:100%;margin-top:12px;background:#0a1620;border:1px solid var(--line2);border-radius:10px;color:var(--text);padding:11px 13px;font-family:inherit;font-size:14px;min-height:80px;resize:vertical}
  #crhub .rev-cta{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:16px;display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:16px;color:var(--muted)}
  #crhub .rev-item{display:flex;gap:13px;padding:15px 0;border-bottom:1px solid var(--line)}
  #crhub .rev-item:last-child{border-bottom:0}
  #crhub .ra{width:40px;height:40px;border-radius:11px;flex:none;background:var(--panel2);border:1px solid var(--line2);display:grid;place-items:center;font-weight:800;color:var(--green)}
  #crhub .rev-top{display:flex;align-items:center;gap:9px;flex-wrap:wrap}
  #crhub .who{font-weight:800} #crhub .when{font:600 11px/1 var(--mono);color:var(--muted2);margin-left:auto}
  #crhub .rev-body p{margin:6px 0 0;color:var(--muted);font-size:14px}
  #crhub .rev-empty{color:var(--muted2)}
  #crhub .pbadge{display:inline-flex;align-items:center;gap:4px;font:700 10px/1 var(--mono);text-transform:uppercase;letter-spacing:.05em;padding:3px 7px;border-radius:6px;background:linear-gradient(145deg,var(--gold),var(--gold-deep));color:#241a06}
  #crhub footer{border-top:1px solid var(--line);margin-top:30px}
  #crhub footer .in{max-width:var(--maxw);margin:0 auto;padding:22px;display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;color:var(--muted2);font-size:13px}
  #crhub footer .dom{font-family:var(--mono)}
  @media(max-width:860px){#crhub .layout{grid-template-columns:1fr}#crhub .side{position:static}#crhub .sidenav{flex-direction:row;flex-wrap:wrap}#crhub .hero{grid-template-columns:1fr}#crhub .cards{grid-template-columns:1fr 1fr}}
  @media(max-width:520px){#crhub .cards{grid-template-columns:1fr}}
</style>

<div id="crhub">
  <div class="top"><div class="in">
    <a class="brand" href="<?= e(BASE) ?>/">
      <div class="logo">💧</div>
      <div><b>Waterborne</b><span data-i18n="brandSub">Minecraft Plugins</span></div>
    </a>
    <a class="navlink" href="<?= e(BASE) ?>/" data-i18n="navHubPlugins">Plugins</a>
    <?php if ($loggedIn): ?>
      <a class="navlink" href="<?= e(BASE) ?>/panel/" data-i18n="navMyPanel">My panel</a>
      <a class="navlink" href="<?= e(BASE) ?>/logout.php" data-i18n="navLogout">Log out</a>
    <?php else: ?>
      <a class="navlink" href="<?= e(BASE) ?>/login.php" data-i18n="navLogin">Log in</a>
      <a class="navlink" href="<?= e(BASE) ?>/register.php" data-i18n="navRegister">Sign up</a>
    <?php endif; ?>
    <div class="langsw">
      <button data-lang="en">EN</button><button data-lang="fr">FR</button><button data-lang="zh">中文</button><button data-lang="es">ES</button>
    </div>
  </div></div>

  <div class="layout">
    <aside class="side">
      <div class="plugsel"><span class="ic">💧</span><div><b>Waterborne</b><small>v1.0 · FREE</small></div></div>
      <div class="sidelabel" data-i18n="sideDocs">Documentation</div>
      <nav class="sidenav">
        <a class="on" data-page="overview"><span class="n">◆</span><span data-i18n="navOverview">Overview</span></a>
        <a data-page="install"><span class="n">▸</span><span data-i18n="navInstall">Installation</span></a>
        <a data-page="thirst"><span class="n">▸</span><span data-i18n="navThirst">Thirst</span></a>
        <a data-page="water"><span class="n">▸</span><span data-i18n="navWater">Water &amp; drinking</span></a>
        <a data-page="parasites"><span class="n">▸</span><span data-i18n="navParasites">Parasites</span></a>
        <a data-page="cures"><span class="n">▸</span><span data-i18n="navCures">Cures</span></a>
        <a data-page="commands"><span class="n">▸</span><span data-i18n="navCommands">Commands</span></a>
        <a data-page="perms"><span class="n">▸</span><span data-i18n="navPerms">Permissions</span></a>
        <a data-page="placeholders"><span class="n">▸</span><span data-i18n="navPlaceholders">Placeholders</span></a>
        <a data-page="config"><span class="n">▸</span><span data-i18n="navConfig">Configuration</span></a>
        <a data-page="reviews"><span class="n">★</span><span data-i18n="navReviews">Reviews</span></a>
      </nav>
    </aside>

    <main class="content">

      <!-- OVERVIEW -->
      <section class="page active" data-p="overview">
        <div class="hero">
          <div>
            <span class="badge"><span class="dot"></span><span data-i18n="heroBadge">Hardcore survival for Minecraft · 1.21+</span></span>
            <h1>Water<span class="grad">borne</span></h1>
            <p class="lede" data-i18n="heroTagline">A hardcore thirst system tied to waterborne parasites. Dirty water quenches your thirst — but it can infect you. Purify water and craft cures to survive.</p>
            <div class="cta">
              <a class="btn primary" href="<?= $DL ?>">⬇ <span data-i18n="btnDownload">Download (free)</span></a>
              <a class="btn ghost" data-page="install" onclick="return false"><span data-i18n="btnInstall">Installation</span></a>
            </div>
            <div class="stats">
              <div class="s"><b>1.0</b><span data-i18n="statVersion">Version</span></div>
              <div class="s"><b>1.21+</b><span data-i18n="statMc">Minecraft</span></div>
              <div class="s"><b data-i18n="statNoneVal">None</b><span data-i18n="statDeps">Required deps</span></div>
              <div class="s"><b>ES·EN·FR·ZH</b><span data-i18n="statLangs">Languages</span></div>
            </div>
          </div>
          <div class="scroll">
            <div class="mrow"><span class="e">💧</span><div><b data-i18n="ovThirst">Thirst</b><small data-i18n="ovThirstEx">Drops as you run &amp; sweat</small></div></div>
            <div class="mrow"><span class="e">🦠</span><div><b data-i18n="ovInfect">Parasites</b><small data-i18n="ovInfectEx">Dirty water infects you</small></div><span class="rr">8</span></div>
            <div class="mrow"><span class="e">💊</span><div><b data-i18n="ovCures">Cures</b><small data-i18n="ovCuresEx">Craft the right remedy</small></div><span class="rr">4</span></div>
            <div class="mrow"><span class="e">🚰</span><div><b data-i18n="ovPurify">Purified water</b><small data-i18n="ovPurifyEx">Safe to drink</small></div></div>
            <div class="mrow"><span class="e">📋</span><div><b data-i18n="ovStatus">Status GUI</b><small data-i18n="ovStatusEx">See cures &amp; recipes</small></div></div>
          </div>
        </div>

        <h3 class="sub" data-i18n="featuresTitle">A complete biological survival loop</h3>
        <div class="cards">
          <div class="card"><div class="ico">💧</div><h3 data-i18n="f1t">Thirst system</h3><p data-i18n="f1d">Thirst drains over time, faster when sprinting or in hot biomes. Low thirst gives debuffs; empty deals damage.</p></div>
          <div class="card"><div class="ico">🦠</div><h3 data-i18n="f2t">8 parasites</h3><p data-i18n="f2d">Some from drinking dirty water, some from swimming. Each drains thirst, hunger or health with symptoms.</p></div>
          <div class="card"><div class="ico">💊</div><h3 data-i18n="f3t">4 craftable cures</h3><p data-i18n="f3d">Each remedy treats a group of parasites and has its own crafting recipe. A broad-spectrum cures anything.</p></div>
          <div class="card"><div class="ico">🚰</div><h3 data-i18n="f4t">Purify water</h3><p data-i18n="f4d">Craft Purified Water — safe, never infects. The bridge between thirst and parasites.</p></div>
          <div class="card"><div class="ico">📋</div><h3 data-i18n="f5t">Status &amp; recipe GUIs</h3><p data-i18n="f5d">/wb status shows your thirst and parasites; click a parasite to see the cure's crafting recipe.</p></div>
          <div class="card"><div class="ico">📊</div><h3 data-i18n="f6t">BossBar / ActionBar</h3><p data-i18n="f6d">Pick how the thirst bar shows — BossBar (no conflicts), ActionBar or none + placeholders.</p></div>
          <div class="card"><div class="ico">🧩</div><h3 data-i18n="f7t">PlaceholderAPI</h3><p data-i18n="f7d">Thirst, percent, bar and parasite count for your own scoreboard or HUD.</p></div>
          <div class="card"><div class="ico">⚙️</div><h3 data-i18n="f8t">Fully configurable</h3><p data-i18n="f8d">Every rate, biome, effect, parasite and cure is editable. Add your own parasites and remedies.</p></div>
          <div class="card"><div class="ico">🌍</div><h3 data-i18n="f9t">4 languages</h3><p data-i18n="f9d">English, Spanish, French and Chinese — every message editable.</p></div>
        </div>
        <div class="note">✅ <div><b data-i18n="noReqT">No required dependencies.</b> <span data-i18n="noReqD">Waterborne runs on its own. PlaceholderAPI is optional and activates automatically. Vault is not needed.</span></div></div>
      </section>

      <!-- INSTALL -->
      <section class="page" data-p="install">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navInstall">Installation</span></div>
        <h2 class="ptitle" data-i18n="navInstall">Installation</h2>
        <p class="plead" data-i18n="instLead">Get Waterborne running in a minute — it needs no other plugin.</p>
        <h3 class="sub" data-i18n="instStepsT">Steps</h3>
        <ol class="steps">
          <li data-i18n="ist1">Download <b>Waterborne.jar</b> and drop it into your server's <b>plugins/</b> folder.</li>
          <li data-i18n="ist2"><b>Restart</b> the server (Java 21 required for 1.21+).</li>
          <li data-i18n="ist3">(Optional) Install PlaceholderAPI if you want placeholders in a scoreboard or HUD.</li>
          <li data-i18n="ist4">Edit <code>config.yml</code> and run <code>/waterborne reload</code>.</li>
        </ol>
        <div class="note">ℹ️ <div><span data-i18n="instNote">Player data (thirst &amp; parasites) is stored in <code>data.yml</code>. Language files are generated on first start in <code>lang/</code>.</span></div></div>
      </section>

      <!-- THIRST -->
      <section class="page" data-p="thirst">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navThirst">Thirst</span></div>
        <h2 class="ptitle" data-i18n="navThirst">Thirst</h2>
        <p class="plead" data-i18n="thLead">Every player has a thirst bar (0–100 by default). It drains over time and you must drink to refill it.</p>
        <div class="tablewrap"><table>
          <tr><th data-i18n="thWhat">Behaviour</th><th data-i18n="thHow">How it works</th></tr>
          <tr><td data-i18n="th1a">Draining</td><td data-i18n="th1b">Loses a base amount each interval — more when sprinting or in a hot biome (desert, nether…).</td></tr>
          <tr><td data-i18n="th2a">Low thirst</td><td data-i18n="th2b">Below configurable thresholds you get effects (slowness, weakness, hunger…).</td></tr>
          <tr><td data-i18n="th3a">Empty (0)</td><td data-i18n="th3b">You take damage until you drink.</td></tr>
          <tr><td data-i18n="th4a">Respawn</td><td data-i18n="th4b">Thirst resets to full on respawn (configurable).</td></tr>
          <tr><td data-i18n="th5a">Display</td><td data-i18n="th5b">BossBar (default), ActionBar or none. Toggle per-player with <code>/wb hud</code>.</td></tr>
        </table></div>
        <div class="note">💧 <div><span data-i18n="thTip">Creative/Spectator players and anyone with <code>waterborne.bypass</code> are not affected. Worlds and game modes are configurable.</span></div></div>
      </section>

      <!-- WATER -->
      <section class="page" data-p="water">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navWater">Water &amp; drinking</span></div>
        <h2 class="ptitle" data-i18n="navWater">Water &amp; drinking</h2>
        <p class="plead" data-i18n="waLead">Water is the core of the plugin: it saves you from thirst, but dirty water can infect you.</p>
        <div class="tablewrap"><table>
          <tr><th data-i18n="waSource">Source</th><th data-i18n="waHow">How to drink</th><th data-i18n="waClean">Clean?</th></tr>
          <tr><td data-i18n="wa1a">Water block / ocean / cauldron</td><td data-i18n="wa1b">Right-click with an empty hand</td><td data-i18n="wa1c">Dirty (configurable)</td></tr>
          <tr><td data-i18n="wa2a">Water bottle</td><td data-i18n="wa2b">Right-click holding it (returns an empty bottle)</td><td data-i18n="wa2c">Dirty (configurable)</td></tr>
          <tr><td data-i18n="wa3a">Purified Water</td><td data-i18n="wa3b">Right-click holding it</td><td data-i18n="wa3c"><b>Always safe</b></td></tr>
        </table></div>
        <h3 class="sub" data-i18n="waPurT">Purified water (the safe option)</h3>
        <p class="plead" data-i18n="waPurD">Purified Water never infects you. Craft it from a water bottle + an ingredient (coal by default). Dirty biomes (swamp, jungle, river…) multiply the infection risk.</p>
        <pre><code><span class="cmt"># default purification recipe (config.yml)</span>
purification:
  recipe:
    enabled: true
    ingredient: COAL     <span class="cmt"># water bottle + coal → Purified Water</span></code></pre>
        <div class="note">🚰 <div><span data-i18n="waTip">Get one instantly for testing: <code>/wb give purified</code>.</span></div></div>
      </section>

      <!-- PARASITES -->
      <section class="page" data-p="parasites">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navParasites">Parasites</span></div>
        <h2 class="ptitle" data-i18n="navParasites">Parasites</h2>
        <p class="plead" data-i18n="paLead">8 parasites are included. Drinking dirty water can give the water-borne ones; swimming in dirty biomes gives the aquatic ones. Each one drains something and adds symptoms.</p>
        <div class="tablewrap"><table>
          <tr><th data-i18n="paName">Parasite</th><th data-i18n="paVia">Caught by</th><th data-i18n="paEffect">Main effect</th></tr>
          <tr><td>Giardia</td><td data-i18n="paDrink">Drinking</td><td data-i18n="pe1">Drains thirst hard + hunger</td></tr>
          <tr><td>Amebiasis</td><td data-i18n="paDrink">Drinking</td><td data-i18n="pe2">Drains thirst + damage + nausea</td></tr>
          <tr><td>Cryptosporidium</td><td data-i18n="paDrink">Drinking</td><td data-i18n="pe3">Drains thirst + hunger + nausea</td></tr>
          <tr><td>Tapeworm</td><td data-i18n="paDrink">Drinking</td><td data-i18n="pe4">Drains hunger + weakness</td></tr>
          <tr><td>Hookworm</td><td data-i18n="paDrink">Drinking</td><td data-i18n="pe5">Weakness + mining fatigue + light damage</td></tr>
          <tr><td>Guinea worm</td><td data-i18n="paDrink">Drinking</td><td data-i18n="pe6">Slowness + light damage</td></tr>
          <tr><td>Leech</td><td data-i18n="paSwim">Swimming</td><td data-i18n="pe7">Drains health</td></tr>
          <tr><td>Schistosoma</td><td data-i18n="paSwim">Swimming</td><td data-i18n="pe8">Drains health hard + weakness</td></tr>
        </table></div>
        <div class="note">📋 <div><span data-i18n="paTip"><code>/wb status</code> shows your parasites, symptoms, which cure treats them and the recipe. Admins: <code>/wb parasite infect|cure|list &lt;player&gt; [type]</code>.</span></div></div>
      </section>

      <!-- CURES -->
      <section class="page" data-p="cures">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navCures">Cures</span></div>
        <h2 class="ptitle" data-i18n="navCures">Cures</h2>
        <p class="plead" data-i18n="cuLead">4 remedies are included. Each cures a group of parasites and has its own crafting recipe. Right-click the remedy to cure one parasite it treats.</p>
        <div class="tablewrap"><table>
          <tr><th data-i18n="cuName">Remedy</th><th data-i18n="cuTreats">Cures</th><th data-i18n="cuRecipe">Recipe (shapeless)</th></tr>
          <tr><td>Antiprotozoal Tonic</td><td>Giardia · Amebiasis · Cryptosporidium</td><td><code>Fermented Spider Eye</code> + <code>Brown Mushroom</code> + <code>Sugar</code></td></tr>
          <tr><td>Deworming Paste</td><td>Tapeworm · Hookworm · Guinea worm</td><td><code>Pumpkin Seeds</code> + <code>Fern</code> + <code>Glow Berries</code></td></tr>
          <tr><td>Aquatic Remedy</td><td>Leech · Schistosoma</td><td><code>Kelp</code> + <code>Seagrass</code> + <code>Fermented Spider Eye</code></td></tr>
          <tr><td>Broad-spectrum</td><td><b>Any parasite</b></td><td><code>Fermented Spider Eye</code> + <code>Golden Apple</code> + <code>Nether Wart</code></td></tr>
        </table></div>
        <div class="note">💊 <div><span data-i18n="cuTip">Give one for testing: <code>/wb give antiprotozoal_tonic</code> (also <code>deworming_paste</code>, <code>aquatic_remedy</code>, <code>broad_antiparasitic</code>). All cures, what they treat and their recipes are configurable.</span></div></div>
      </section>

      <!-- COMMANDS -->
      <section class="page" data-p="commands">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navCommands">Commands</span></div>
        <h2 class="ptitle" data-i18n="navCommands">Commands</h2>
        <p class="plead" data-i18n="cmdLead">Base command <code>/waterborne</code> — aliases <code>/wb</code>, <code>/thirst</code>, <code>/sed</code>.</p>
        <h3 class="sub" data-i18n="cmdPlayerT">Players</h3>
        <div class="tablewrap"><table>
          <tr><th data-i18n="thCmd">Command</th><th data-i18n="thDesc">What it does</th></tr>
          <tr><td><code>/wb status</code></td><td data-i18n="pc1">Open your status GUI (thirst, parasites, cures)</td></tr>
          <tr><td><code>/wb hud</code></td><td data-i18n="pc2">Toggle your thirst bar</td></tr>
          <tr><td><code>/wb help</code></td><td data-i18n="pc3">Command list</td></tr>
          <tr><td><code>/wb version</code></td><td data-i18n="pc4">Plugin version &amp; author</td></tr>
        </table></div>
        <h3 class="sub" data-i18n="cmdAdminT">Admin</h3>
        <div class="tablewrap"><table>
          <tr><th data-i18n="thCmd">Command</th><th data-i18n="thDesc">What it does</th></tr>
          <tr><td><code>/wb thirst &lt;get|set|add&gt; &lt;player&gt; [n]</code></td><td data-i18n="ac1">Manage a player's thirst</td></tr>
          <tr><td><code>/wb parasite &lt;infect|cure|list&gt; &lt;player&gt; [type]</code></td><td data-i18n="ac2">Manage parasites</td></tr>
          <tr><td><code>/wb give &lt;purified|remedy-key&gt; [player] [n]</code></td><td data-i18n="ac3">Give purified water or a remedy</td></tr>
          <tr><td><code>/wb reload</code></td><td data-i18n="ac4">Reload config &amp; languages</td></tr>
        </table></div>
      </section>

      <!-- PERMISSIONS -->
      <section class="page" data-p="perms">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navPerms">Permissions</span></div>
        <h2 class="ptitle" data-i18n="navPerms">Permissions</h2>
        <p class="plead" data-i18n="permLead">Grant these with LuckPerms or any permissions plugin.</p>
        <div class="tablewrap"><table>
          <tr><th data-i18n="thPerm">Permission</th><th data-i18n="thDesc">What it does</th><th data-i18n="thDefault">Default</th></tr>
          <tr><td><span class="perm">waterborne.use</span></td><td data-i18n="pp1">Affected by thirst &amp; parasites (base)</td><td><b>true</b></td></tr>
          <tr><td><span class="perm">waterborne.bypass</span></td><td data-i18n="pp2">Immune to thirst &amp; parasites</td><td>false</td></tr>
          <tr><td><span class="perm">waterborne.admin</span></td><td data-i18n="pp3">All admin commands (thirst, parasite, give, reload)</td><td>op</td></tr>
        </table></div>
      </section>

      <!-- PLACEHOLDERS -->
      <section class="page" data-p="placeholders">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navPlaceholders">Placeholders</span></div>
        <h2 class="ptitle" data-i18n="navPlaceholders">Placeholders</h2>
        <p class="plead" data-i18n="phLead">Requires PlaceholderAPI. Great for a scoreboard or a custom HUD (set <code>display.mode: NONE</code> and render the bar yourself).</p>
        <pre><code>%waterborne_thirst%          <span class="cmt"># current thirst</span>
%waterborne_thirst_max%      <span class="cmt"># max thirst</span>
%waterborne_thirst_percent%  <span class="cmt"># thirst %</span>
%waterborne_thirst_bar%      <span class="cmt"># text bar</span>
%waterborne_parasites%       <span class="cmt"># number of parasites</span>
%waterborne_infected%        <span class="cmt"># true / false</span></code></pre>
      </section>

      <!-- CONFIG -->
      <section class="page" data-p="config">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navConfig">Configuration</span></div>
        <h2 class="ptitle" data-i18n="navConfig">Configuration</h2>
        <p class="plead" data-i18n="cfgLead">One clean, commented <code>config.yml</code>. Everything below is editable, and you can add your own parasites and cures.</p>
        <div class="tablewrap"><table>
          <tr><th data-i18n="cfgSection">Section</th><th data-i18n="cfgWhat">What it controls</th></tr>
          <tr><td><code>general</code></td><td data-i18n="cg1">Enabled worlds &amp; affected game modes</td></tr>
          <tr><td><code>thirst</code></td><td data-i18n="cg2">Max, drain rate, hot biomes, effects by threshold, damage at zero</td></tr>
          <tr><td><code>display</code></td><td data-i18n="cg3">BOSSBAR / ACTIONBAR / NONE, colors, format</td></tr>
          <tr><td><code>drinking</code></td><td data-i18n="cg4">How much each source restores &amp; whether it's dirty</td></tr>
          <tr><td><code>water · purification</code></td><td data-i18n="cg5">Dirty biomes, risk multiplier, purified-water recipe</td></tr>
          <tr><td><code>parasites</code></td><td data-i18n="cg6">Infection chances, tick rate, clear-on-death, the 8 parasites</td></tr>
          <tr><td><code>cures</code></td><td data-i18n="cg7">The remedies: what they treat, their item &amp; recipe</td></tr>
        </table></div>

        <h3 class="sub" data-i18n="cfgThirstT">Thirst &amp; display</h3>
        <pre><code>thirst:
  max: 100.0
  decay:
    interval-ticks: 120   <span class="cmt"># 20 ticks = 1s</span>
    base: 1.0
    sprint-extra: 1.0
    hot-biome-extra: 1.5
  effects:                <span class="cmt"># applied when thirst &lt;= threshold</span>
    '25': [ "slowness:0" ]
    '10': [ "slowness:1", "weakness:0" ]
    '3':  [ "slowness:2", "weakness:1", "hunger:0" ]
  damage-at-zero: { enabled: true, amount: 1.0 }

display:
  mode: BOSSBAR           <span class="cmt"># BOSSBAR | ACTIONBAR | NONE</span>
  show-below-percent: 100 <span class="cmt"># only show when thirst is below this %</span></code></pre>

        <h3 class="sub" data-i18n="cfgParaT">Add a parasite</h3>
        <pre><code>parasites:
  types:
    giardia:
      name: "&lt;#7CFC00&gt;Giardia"
      description: [ "&lt;gray&gt;Intestinal protozoan from stagnant water." ]
      drain-thirst: 4.0
      drain-hunger: 0
      damage: 0.0
      effects: [ "hunger:0" ]   <span class="cmt"># effect:amplifier</span>
      weight: 40                <span class="cmt"># relative chance to roll</span>
      icon: SLIME_BALL          <span class="cmt"># icon in /wb status</span></code></pre>

        <h3 class="sub" data-i18n="cfgCureT">Add a cure</h3>
        <pre><code>cures:
  antiprotozoal_tonic:
    name: "&lt;#7CFC00&gt;Antiprotozoal Tonic"
    material: FERMENTED_SPIDER_EYE
    treats: [ giardia, amebiasis, cryptosporidium ]
    consume: true
    recipe:
      enabled: true
      ingredients: [ FERMENTED_SPIDER_EYE, BROWN_MUSHROOM, SUGAR ]</code></pre>
        <div class="note">ℹ️ <div><span data-i18n="cfgNote">After editing, run <code>/waterborne reload</code>. New recipes register on start/reload; changing an existing recipe's ingredients needs a restart.</span></div></div>
      </section>

      <!-- REVIEWS -->
      <section class="page" data-p="reviews">
        <div class="crumb"><b>Waterborne</b> / <span data-i18n="navReviews">Reviews</span></div>
        <h2 class="ptitle" data-i18n="reviewsTitle">Player reviews</h2>
        <p class="plead" data-i18n="reviewsSub">What server owners think of Waterborne.</p>
        <div class="rev-head">
          <div class="rev-avg"><?= $revTotal ? number_format($revAvg,1) : '—' ?></div>
          <div>
            <div class="rev-st"><?= $revTotal ? rw_stars((int)round($revAvg)) : '<span class="off">★★★★★</span>' ?></div>
            <div style="font:600 12px/1 var(--mono);color:var(--muted2);margin-top:5px"><?= $revTotal ?> <span data-i18n="reviewsWord">reviews</span></div>
          </div>
        </div>

        <?php if ($revMsg): ?><div class="note" style="border-color:rgba(246,196,83,.4)"><?= e($revMsg) ?></div><?php endif; ?>

        <?php if ($loggedIn): ?>
          <div class="rev-form">
            <div style="font-weight:800;margin-bottom:10px"><?= $myRev ? '<span data-i18n="reviewEditT">Edit your review</span>' : '<span data-i18n="reviewWriteT">Write a review</span>' ?></div>
            <form method="post">
              <?= csrf_field() ?>
              <input type="hidden" name="do" value="review">
              <input type="hidden" name="rating" id="rating" value="<?= $myRev ? (int)$myRev['rating'] : 0 ?>">
              <div class="starpick" id="starpick">
                <span data-v="1">★</span><span data-v="2">★</span><span data-v="3">★</span><span data-v="4">★</span><span data-v="5">★</span>
              </div>
              <textarea class="rev-ta" name="comment" maxlength="1000" data-i18n-ph="reviewPh" placeholder="Share your experience…"><?= htmlspecialchars($myRev['comment'] ?? '', ENT_QUOTES) ?></textarea>
              <div style="margin-top:12px"><button class="btn primary" type="submit"><?= $myRev ? '<span data-i18n="reviewUpdate">Update review</span>' : '<span data-i18n="reviewPublish">Publish review</span>' ?></button></div>
            </form>
          </div>
        <?php else: ?>
          <div class="rev-cta">
            <span data-i18n="reviewsLoginPrompt">Log in to leave a review.</span>
            <a class="btn ghost" href="<?= e(BASE) ?>/login.php" data-i18n="navLogin">Log in</a>
          </div>
        <?php endif; ?>

        <div class="rev-list">
          <?php if ($revList): foreach ($revList as $r):
            $ini = strtoupper(mb_substr($r['username'], 0, 2));
            $cmt = nl2br(htmlspecialchars($r['comment'], ENT_QUOTES, 'UTF-8')); ?>
            <div class="rev-item">
              <span class="ra"><?= htmlspecialchars($ini, ENT_QUOTES) ?></span>
              <div class="rev-body">
                <div class="rev-top">
                  <span class="who"><?= htmlspecialchars($r['username'], ENT_QUOTES) ?></span>
                  <?= review_badges(($r['role'] ?? '')==='admin', $r['owned']) ?>
                  <span class="when"><?= date('d M Y', strtotime($r['created_at'])) ?></span>
                </div>
                <div class="rev-st"><?= rw_stars((int)$r['rating']) ?></div>
                <p><?= $cmt ?></p>
                <?php if (!empty($replies[(int)$r['id']])): $rep = $replies[(int)$r['id']]; ?>
                  <div class="adminreply">
                    <div class="arhead"><?= role_badge(true) ?><span class="lbl">infinity3113</span><span class="when"><?= date('d M Y', strtotime($rep['admin_reply_at'])) ?></span></div>
                    <p><?= nl2br(htmlspecialchars($rep['admin_reply'], ENT_QUOTES, 'UTF-8')) ?></p>
                  </div>
                <?php endif; ?>
              </div>
            </div>
          <?php endforeach; else: ?>
            <p class="rev-empty" data-i18n="reviewsNone">No reviews yet — be the first!</p>
          <?php endif; ?>
        </div>
      </section>

    </main>
  </div>

  <footer><div class="in">
    <span data-i18n="footMade">Made by infinity3113 · Waterborne</span>
    <span class="dom">infinity3113.mc-paradise.com/plugins/waterborne</span>
  </div></footer>
</div>

<script>
(function(){
  var I18N={
    es:{brandSub:"Plugins de Minecraft",sideDocs:"Documentación",navHubPlugins:"Plugins",navMyPanel:"Mi panel",navLogout:"Salir",navLogin:"Entrar",navRegister:"Crear cuenta",
      navOverview:"Resumen",navInstall:"Instalación",navThirst:"Sed",navWater:"Agua y beber",navParasites:"Parásitos",navCures:"Curas",navCommands:"Comandos",navPerms:"Permisos",navPlaceholders:"Placeholders",navConfig:"Configuración",navReviews:"Reseñas",
      heroBadge:"Supervivencia hardcore · 1.21+",heroTagline:"Un sistema de sed hardcore ligado a parásitos del agua. El agua sucia calma la sed, pero puede infectarte. Purifica el agua y craftea curas para sobrevivir.",
      btnDownload:"Descargar (gratis)",btnInstall:"Instalación",statVersion:"Versión",statMc:"Minecraft",statNoneVal:"Ninguna",statDeps:"Dependencias",statLangs:"Idiomas",
      ovThirst:"Sed",ovThirstEx:"Baja al correr y sudar",ovInfect:"Parásitos",ovInfectEx:"El agua sucia infecta",ovCures:"Curas",ovCuresEx:"Craftea el remedio correcto",ovPurify:"Agua purificada",ovPurifyEx:"Segura de beber",ovStatus:"GUI de estado",ovStatusEx:"Ve curas y recetas",
      featuresTitle:"Un ciclo completo de supervivencia biológica",
      f1t:"Sistema de sed",f1d:"La sed baja con el tiempo, más rápido al esprintar o en biomas calurosos. Poca sed da debuffs; a 0 recibes daño.",
      f2t:"8 parásitos",f2d:"Unos por beber agua sucia, otros por nadar. Cada uno drena sed, hambre o vida con síntomas.",
      f3t:"4 curas crafteables",f3d:"Cada remedio cura un grupo de parásitos y tiene su propia receta. Uno de amplio espectro cura todo.",
      f4t:"Purificar agua",f4d:"Craftea Agua Purificada — segura, nunca infecta. El nexo entre sed y parásitos.",
      f5t:"GUIs de estado y receta",f5d:"/wb status muestra sed y parásitos; clic en un parásito para ver la receta de su cura.",
      f6t:"BossBar / ActionBar",f6d:"Elige cómo se ve la barra de sed: BossBar (sin conflictos), ActionBar o ninguna + placeholders.",
      f7t:"PlaceholderAPI",f7d:"Sed, porcentaje, barra y número de parásitos para tu propio scoreboard o HUD.",
      f8t:"Totalmente configurable",f8d:"Cada tasa, bioma, efecto, parásito y cura es editable. Añade tus propios parásitos y remedios.",
      f9t:"4 idiomas",f9d:"Inglés, Español, Francés y Chino — cada mensaje editable.",
      noReqT:"Sin dependencias obligatorias.",noReqD:"Waterborne funciona solo. PlaceholderAPI es opcional y se activa solo. No necesita Vault.",
      instLead:"Pon Waterborne en marcha en un minuto — no necesita ningún otro plugin.",instStepsT:"Pasos",
      ist1:"Descarga <b>Waterborne.jar</b> y ponlo en la carpeta <b>plugins/</b> de tu servidor.",ist2:"<b>Reinicia</b> el servidor (se requiere Java 21 para 1.21+).",ist3:"(Opcional) Instala PlaceholderAPI si quieres placeholders en un scoreboard o HUD.",ist4:"Edita <code>config.yml</code> y ejecuta <code>/waterborne reload</code>.",
      instNote:"Los datos del jugador (sed y parásitos) se guardan en <code>data.yml</code>. Los idiomas se generan al primer arranque en <code>lang/</code>.",
      thLead:"Cada jugador tiene una barra de sed (0–100 por defecto). Baja con el tiempo y debes beber para reponerla.",
      thWhat:"Comportamiento",thHow:"Cómo funciona",
      th1a:"Baja",th1b:"Pierde una cantidad base por intervalo — más al esprintar o en bioma caluroso (desierto, nether…).",
      th2a:"Sed baja",th2b:"Por debajo de umbrales configurables recibes efectos (lentitud, debilidad, hambre…).",
      th3a:"Vacía (0)",th3b:"Recibes daño hasta que bebas.",
      th4a:"Reaparecer",th4b:"La sed vuelve a llenarse al reaparecer (configurable).",
      th5a:"Pantalla",th5b:"BossBar (por defecto), ActionBar o ninguna. Cada jugador con <code>/wb hud</code>.",
      thTip:"Los jugadores en Creativo/Espectador y quien tenga <code>waterborne.bypass</code> no se ven afectados. Mundos y modos de juego son configurables.",
      waLead:"El agua es el núcleo del plugin: te salva de la sed, pero el agua sucia puede infectarte.",
      waSource:"Fuente",waHow:"Cómo beber",waClean:"¿Limpia?",
      wa1a:"Bloque de agua / océano / caldero",wa1b:"Clic derecho con la mano vacía",wa1c:"Sucia (configurable)",
      wa2a:"Botella de agua",wa2b:"Clic derecho sosteniéndola (deja botella vacía)",wa2c:"Sucia (configurable)",
      wa3a:"Agua Purificada",wa3b:"Clic derecho sosteniéndola",wa3c:"<b>Siempre segura</b>",
      waPurT:"Agua purificada (la opción segura)",waPurD:"El Agua Purificada nunca infecta. Se craftea con botella de agua + un ingrediente (carbón por defecto). Los biomas sucios (pantano, jungla, río…) multiplican el riesgo.",
      waTip:"Consigue una para probar: <code>/wb give purified</code>.",
      paLead:"Se incluyen 8 parásitos. Beber agua sucia da los de agua; nadar en biomas sucios da los acuáticos. Cada uno drena algo y añade síntomas.",
      paName:"Parásito",paVia:"Se contagia por",paEffect:"Efecto principal",paDrink:"Beber",paSwim:"Nadar",
      pe1:"Drena mucha sed + hambre",pe2:"Drena sed + daño + náusea",pe3:"Drena sed + hambre + náusea",pe4:"Drena hambre + debilidad",pe5:"Debilidad + fatiga + daño leve",pe6:"Lentitud + daño leve",pe7:"Drena vida",pe8:"Drena mucha vida + debilidad",
      paTip:"<code>/wb status</code> muestra tus parásitos, síntomas, qué cura los trata y la receta. Admins: <code>/wb parasite infect|cure|list &lt;jugador&gt; [tipo]</code>.",
      cuLead:"Se incluyen 4 remedios. Cada uno cura un grupo de parásitos y tiene su receta. Clic derecho en el remedio para curar un parásito que trate.",
      cuName:"Remedio",cuTreats:"Cura",cuRecipe:"Receta (sin forma)",
      cuTip:"Da uno para probar: <code>/wb give antiprotozoal_tonic</code> (también <code>deworming_paste</code>, <code>aquatic_remedy</code>, <code>broad_antiparasitic</code>). Todo es configurable.",
      cmdLead:"Comando base <code>/waterborne</code> — alias <code>/wb</code>, <code>/thirst</code>, <code>/sed</code>.",cmdPlayerT:"Jugadores",cmdAdminT:"Administración",thCmd:"Comando",thDesc:"Qué hace",
      pc1:"Abre tu GUI de estado (sed, parásitos, curas)",pc2:"Activa/desactiva tu barra de sed",pc3:"Lista de comandos",pc4:"Versión y autor del plugin",
      ac1:"Gestiona la sed de un jugador",ac2:"Gestiona parásitos",ac3:"Da agua purificada o un remedio",ac4:"Recarga config e idiomas",
      permLead:"Otórgalos con LuckPerms o cualquier plugin de permisos.",thPerm:"Permiso",thDefault:"Por defecto",
      pp1:"Le afectan sed y parásitos (base)",pp2:"Inmune a sed y parásitos",pp3:"Todos los comandos admin (thirst, parasite, give, reload)",
      phLead:"Requiere PlaceholderAPI. Ideal para un scoreboard o HUD propio (pon <code>display.mode: NONE</code> y dibuja la barra tú).",
      cfgLead:"Un solo <code>config.yml</code> limpio y comentado. Todo es editable, y puedes añadir tus propios parásitos y curas.",
      cfgSection:"Sección",cfgWhat:"Qué controla",
      cg1:"Mundos habilitados y modos de juego afectados",cg2:"Máximo, tasa de pérdida, biomas calurosos, efectos por umbral, daño a 0",cg3:"BOSSBAR / ACTIONBAR / NONE, colores, formato",cg4:"Cuánto repone cada fuente y si es sucia",cg5:"Biomas sucios, multiplicador de riesgo, receta de agua purificada",cg6:"Probabilidades de infección, ritmo, quitar al morir, los 8 parásitos",cg7:"Los remedios: qué curan, su ítem y su receta",
      cfgThirstT:"Sed y pantalla",cfgParaT:"Añadir un parásito",cfgCureT:"Añadir una cura",
      cfgNote:"Tras editar, ejecuta <code>/waterborne reload</code>. Las recetas nuevas se registran al arrancar/recargar; cambiar los ingredientes de una receta existente requiere reiniciar.",
      reviewsTitle:"Reseñas de jugadores",reviewsSub:"Lo que opinan los dueños de servidores sobre Waterborne.",reviewsWord:"reseñas",
      reviewWriteT:"Escribe una reseña",reviewEditT:"Edita tu reseña",reviewPublish:"Publicar reseña",reviewUpdate:"Actualizar reseña",reviewPh:"Comparte tu experiencia…",
      reviewsLoginPrompt:"Inicia sesión para dejar una reseña.",reviewsNone:"Aún no hay reseñas — ¡sé el primero!",footMade:"Hecho por infinity3113 · Waterborne"},
    fr:{brandSub:"Plugins Minecraft",sideDocs:"Documentation",navHubPlugins:"Plugins",navMyPanel:"Mon panneau",navLogout:"Déconnexion",navLogin:"Connexion",navRegister:"S'inscrire",
      navOverview:"Aperçu",navInstall:"Installation",navThirst:"Soif",navWater:"Eau et boisson",navParasites:"Parasites",navCures:"Remèdes",navCommands:"Commandes",navPerms:"Permissions",navPlaceholders:"Placeholders",navConfig:"Configuration",navReviews:"Avis",
      heroBadge:"Survie hardcore · 1.21+",heroTagline:"Un système de soif hardcore lié aux parasites de l'eau. L'eau sale étanche la soif, mais peut t'infecter. Purifie l'eau et fabrique des remèdes pour survivre.",
      btnDownload:"Télécharger (gratuit)",btnInstall:"Installation",statVersion:"Version",statMc:"Minecraft",statNoneVal:"Aucune",statDeps:"Dépendances",statLangs:"Langues",
      ovThirst:"Soif",ovThirstEx:"Baisse en courant et suant",ovInfect:"Parasites",ovInfectEx:"L'eau sale t'infecte",ovCures:"Remèdes",ovCuresEx:"Fabrique le bon remède",ovPurify:"Eau purifiée",ovPurifyEx:"Sûre à boire",ovStatus:"Interface d'état",ovStatusEx:"Vois remèdes et recettes",
      featuresTitle:"Une boucle de survie biologique complète",
      f1t:"Système de soif",f1d:"La soif baisse avec le temps, plus vite en courant ou dans les biomes chauds. Peu de soif donne des malus ; à 0 tu subis des dégâts.",
      f2t:"8 parasites",f2d:"Certains en buvant de l'eau sale, d'autres en nageant. Chacun draine soif, faim ou vie avec des symptômes.",
      f3t:"4 remèdes fabricables",f3d:"Chaque remède soigne un groupe de parasites et a sa propre recette. Un à large spectre soigne tout.",
      f4t:"Purifier l'eau",f4d:"Fabrique de l'Eau Purifiée — sûre, n'infecte jamais. Le pont entre soif et parasites.",
      f5t:"Interfaces état et recette",f5d:"/wb status montre ta soif et tes parasites ; clique un parasite pour voir la recette de son remède.",
      f6t:"BossBar / ActionBar",f6d:"Choisis l'affichage de la barre de soif : BossBar (sans conflit), ActionBar ou aucune + placeholders.",
      f7t:"PlaceholderAPI",f7d:"Soif, pourcentage, barre et nombre de parasites pour ton propre scoreboard/HUD.",
      f8t:"Entièrement configurable",f8d:"Chaque taux, biome, effet, parasite et remède est éditable. Ajoute les tiens.",
      f9t:"4 langues",f9d:"Anglais, Espagnol, Français et Chinois — chaque message éditable.",
      noReqT:"Aucune dépendance requise.",noReqD:"Waterborne fonctionne seul. PlaceholderAPI est optionnel et s'active tout seul. Vault n'est pas nécessaire.",
      instLead:"Mets Waterborne en route en une minute — aucun autre plugin requis.",instStepsT:"Étapes",
      ist1:"Télécharge <b>Waterborne.jar</b> et place-le dans le dossier <b>plugins/</b> de ton serveur.",ist2:"<b>Redémarre</b> le serveur (Java 21 requis pour 1.21+).",ist3:"(Optionnel) Installe PlaceholderAPI pour des placeholders dans un scoreboard ou HUD.",ist4:"Édite <code>config.yml</code> puis lance <code>/waterborne reload</code>.",
      instNote:"Les données joueur (soif et parasites) sont dans <code>data.yml</code>. Les langues sont générées au premier démarrage dans <code>lang/</code>.",
      thLead:"Chaque joueur a une barre de soif (0–100 par défaut). Elle baisse avec le temps et il faut boire pour la remplir.",
      thWhat:"Comportement",thHow:"Fonctionnement",
      th1a:"Baisse",th1b:"Perd une valeur de base par intervalle — plus en courant ou en biome chaud (désert, nether…).",
      th2a:"Soif basse",th2b:"Sous des seuils configurables, tu reçois des effets (lenteur, faiblesse, faim…).",
      th3a:"Vide (0)",th3b:"Tu subis des dégâts jusqu'à ce que tu boives.",
      th4a:"Réapparition",th4b:"La soif se remplit à la réapparition (configurable).",
      th5a:"Affichage",th5b:"BossBar (défaut), ActionBar ou aucun. Par joueur avec <code>/wb hud</code>.",
      thTip:"Les joueurs en Créatif/Spectateur et ceux avec <code>waterborne.bypass</code> ne sont pas affectés. Mondes et modes de jeu configurables.",
      waLead:"L'eau est au cœur du plugin : elle te sauve de la soif, mais l'eau sale peut t'infecter.",
      waSource:"Source",waHow:"Comment boire",waClean:"Propre ?",
      wa1a:"Bloc d'eau / océan / chaudron",wa1b:"Clic droit main vide",wa1c:"Sale (configurable)",
      wa2a:"Bouteille d'eau",wa2b:"Clic droit en la tenant (rend une bouteille vide)",wa2c:"Sale (configurable)",
      wa3a:"Eau Purifiée",wa3b:"Clic droit en la tenant",wa3c:"<b>Toujours sûre</b>",
      waPurT:"Eau purifiée (l'option sûre)",waPurD:"L'Eau Purifiée n'infecte jamais. Fabrique-la avec une bouteille d'eau + un ingrédient (charbon par défaut). Les biomes sales (marais, jungle, rivière…) multiplient le risque.",
      waTip:"Obtiens-en une pour tester : <code>/wb give purified</code>.",
      paLead:"8 parasites inclus. Boire de l'eau sale donne ceux de l'eau ; nager en biome sale donne les aquatiques. Chacun draine quelque chose et ajoute des symptômes.",
      paName:"Parasite",paVia:"Attrapé par",paEffect:"Effet principal",paDrink:"Boire",paSwim:"Nager",
      pe1:"Draine fort la soif + faim",pe2:"Draine soif + dégâts + nausée",pe3:"Draine soif + faim + nausée",pe4:"Draine faim + faiblesse",pe5:"Faiblesse + fatigue + légers dégâts",pe6:"Lenteur + légers dégâts",pe7:"Draine la vie",pe8:"Draine fort la vie + faiblesse",
      paTip:"<code>/wb status</code> montre tes parasites, symptômes, quel remède les soigne et la recette. Admins : <code>/wb parasite infect|cure|list &lt;joueur&gt; [type]</code>.",
      cuLead:"4 remèdes inclus. Chacun soigne un groupe de parasites et a sa recette. Clic droit sur le remède pour soigner un parasite qu'il traite.",
      cuName:"Remède",cuTreats:"Soigne",cuRecipe:"Recette (sans forme)",
      cuTip:"Donnes-en un pour tester : <code>/wb give antiprotozoal_tonic</code> (aussi <code>deworming_paste</code>, <code>aquatic_remedy</code>, <code>broad_antiparasitic</code>). Tout est configurable.",
      cmdLead:"Commande de base <code>/waterborne</code> — alias <code>/wb</code>, <code>/thirst</code>, <code>/sed</code>.",cmdPlayerT:"Joueurs",cmdAdminT:"Administration",thCmd:"Commande",thDesc:"Effet",
      pc1:"Ouvre ton interface d'état (soif, parasites, remèdes)",pc2:"Active/désactive ta barre de soif",pc3:"Liste des commandes",pc4:"Version et auteur",
      ac1:"Gère la soif d'un joueur",ac2:"Gère les parasites",ac3:"Donne de l'eau purifiée ou un remède",ac4:"Recharge config et langues",
      permLead:"Attribue-les avec LuckPerms ou tout plugin de permissions.",thPerm:"Permission",thDefault:"Défaut",
      pp1:"Affecté par soif et parasites (base)",pp2:"Immunisé contre soif et parasites",pp3:"Toutes les commandes admin (thirst, parasite, give, reload)",
      phLead:"Nécessite PlaceholderAPI. Parfait pour un scoreboard ou HUD (mets <code>display.mode: NONE</code> et dessine la barre toi-même).",
      cfgLead:"Un seul <code>config.yml</code> propre et commenté. Ajoute tes propres parasites et remèdes.",
      cfgSection:"Section",cfgWhat:"Ce qu'elle contrôle",
      cg1:"Mondes activés et modes de jeu affectés",cg2:"Max, taux de baisse, biomes chauds, effets par seuil, dégâts à 0",cg3:"BOSSBAR / ACTIONBAR / NONE, couleurs, format",cg4:"Ce que chaque source restaure et si elle est sale",cg5:"Biomes sales, multiplicateur de risque, recette de l'eau purifiée",cg6:"Chances d'infection, cadence, retrait à la mort, les 8 parasites",cg7:"Les remèdes : ce qu'ils soignent, leur objet et leur recette",
      cfgThirstT:"Soif et affichage",cfgParaT:"Ajouter un parasite",cfgCureT:"Ajouter un remède",
      cfgNote:"Après édition, lance <code>/waterborne reload</code>. Les nouvelles recettes s'enregistrent au démarrage/rechargement ; changer les ingrédients d'une recette existante requiert un redémarrage.",
      reviewsTitle:"Avis des joueurs",reviewsSub:"Ce que les propriétaires de serveurs pensent de Waterborne.",reviewsWord:"avis",
      reviewWriteT:"Écrire un avis",reviewEditT:"Modifier ton avis",reviewPublish:"Publier l'avis",reviewUpdate:"Mettre à jour",reviewPh:"Partage ton expérience…",
      reviewsLoginPrompt:"Connecte-toi pour laisser un avis.",reviewsNone:"Aucun avis pour l'instant — sois le premier !",footMade:"Créé par infinity3113 · Waterborne"},
    zh:{brandSub:"Minecraft 插件",sideDocs:"文档",navHubPlugins:"插件",navMyPanel:"我的面板",navLogout:"退出",navLogin:"登录",navRegister:"注册",
      navOverview:"概览",navInstall:"安装",navThirst:"口渴",navWater:"水与饮水",navParasites:"寄生虫",navCures:"治疗",navCommands:"指令",navPerms:"权限",navPlaceholders:"占位符",navConfig:"配置",navReviews:"评价",
      heroBadge:"硬核生存 · 1.21+",heroTagline:"一套与水源寄生虫相连的硬核口渴系统。脏水能解渴，却可能让你感染。净化水源、制作治疗剂以求生存。",
      btnDownload:"下载（免费）",btnInstall:"安装",statVersion:"版本",statMc:"Minecraft",statNoneVal:"无",statDeps:"依赖",statLangs:"语言",
      ovThirst:"口渴",ovThirstEx:"奔跑流汗时下降",ovInfect:"寄生虫",ovInfectEx:"脏水会让你感染",ovCures:"治疗",ovCuresEx:"制作正确的治疗剂",ovPurify:"净化水",ovPurifyEx:"可安全饮用",ovStatus:"状态界面",ovStatusEx:"查看治疗与配方",
      featuresTitle:"完整的生物生存循环",
      f1t:"口渴系统",f1d:"口渴随时间下降，奔跑或炎热生物群系下更快。口渴低会有减益；归零则受到伤害。",
      f2t:"8 种寄生虫",f2d:"有的来自喝脏水，有的来自游泳。每种都会消耗口渴、饥饿或生命并带来症状。",
      f3t:"4 种可合成治疗剂",f3d:"每种治疗剂医治一组寄生虫且有自己的配方；广谱治疗剂医治全部。",
      f4t:"净化水",f4d:"合成净化水——安全、绝不感染。是口渴与寄生虫之间的桥梁。",
      f5t:"状态与配方界面",f5d:"/wb status 显示口渴与寄生虫；点击寄生虫查看其治疗剂配方。",
      f6t:"BossBar / ActionBar",f6d:"选择口渴条的显示：BossBar（无冲突）、ActionBar 或 NONE + 占位符。",
      f7t:"PlaceholderAPI",f7d:"口渴、百分比、进度条与寄生虫数量，用于你自己的计分板/HUD。",
      f8t:"完全可配置",f8d:"每项速率、生物群系、效果、寄生虫与治疗剂都可编辑。可自行添加。",
      f9t:"4 种语言",f9d:"英语、西班牙语、法语和中文——每条消息可编辑。",
      noReqT:"无需任何依赖。",noReqD:"Waterborne 可独立运行。PlaceholderAPI 为可选并会自动启用。无需 Vault。",
      instLead:"一分钟即可运行 Waterborne——无需任何其他插件。",instStepsT:"步骤",
      ist1:"下载 <b>Waterborne.jar</b> 并放入服务器的 <b>plugins/</b> 文件夹。",ist2:"<b>重启</b>服务器（1.21+ 需要 Java 21）。",ist3:"（可选）安装 PlaceholderAPI 以在计分板或 HUD 使用占位符。",ist4:"编辑 <code>config.yml</code> 并运行 <code>/waterborne reload</code>。",
      instNote:"玩家数据（口渴与寄生虫）保存在 <code>data.yml</code>。语言文件在首次启动时于 <code>lang/</code> 生成。",
      thLead:"每位玩家都有一条口渴条（默认 0–100）。它随时间下降，必须喝水补充。",
      thWhat:"行为",thHow:"运作方式",
      th1a:"下降",th1b:"每个间隔损失基础值——奔跑或炎热生物群系（沙漠、下界…）更多。",
      th2a:"口渴过低",th2b:"低于可配置阈值会获得效果（缓慢、虚弱、饥饿…）。",
      th3a:"归零 (0)",th3b:"在你喝水之前持续受到伤害。",
      th4a:"重生",th4b:"重生时口渴恢复满值（可配置）。",
      th5a:"显示",th5b:"BossBar（默认）、ActionBar 或无。每位玩家用 <code>/wb hud</code> 切换。",
      thTip:"创造/旁观玩家以及拥有 <code>waterborne.bypass</code> 的人不受影响。世界与游戏模式可配置。",
      waLead:"水是插件的核心：它救你于口渴，但脏水会让你感染。",
      waSource:"来源",waHow:"如何饮用",waClean:"干净？",
      wa1a:"水方块 / 海洋 / 炼药锅",wa1b:"空手右键",wa1c:"脏（可配置）",
      wa2a:"水瓶",wa2b:"手持右键（返还空瓶）",wa2c:"脏（可配置）",
      wa3a:"净化水",wa3b:"手持右键",wa3c:"<b>始终安全</b>",
      waPurT:"净化水（安全之选）",waPurD:"净化水绝不感染。用水瓶 + 一种材料（默认煤炭）合成。脏生物群系（沼泽、丛林、河流…）会使风险翻倍。",
      waTip:"获取一份用于测试：<code>/wb give purified</code>。",
      paLead:"内置 8 种寄生虫。喝脏水会得到水源类；在脏生物群系游泳会得到水生类。每种都会消耗某项并带来症状。",
      paName:"寄生虫",paVia:"感染途径",paEffect:"主要效果",paDrink:"饮水",paSwim:"游泳",
      pe1:"大量消耗口渴 + 饥饿",pe2:"消耗口渴 + 伤害 + 反胃",pe3:"消耗口渴 + 饥饿 + 反胃",pe4:"消耗饥饿 + 虚弱",pe5:"虚弱 + 挖掘疲劳 + 轻微伤害",pe6:"缓慢 + 轻微伤害",pe7:"消耗生命",pe8:"大量消耗生命 + 虚弱",
      paTip:"<code>/wb status</code> 显示你的寄生虫、症状、由哪种治疗剂医治及配方。管理员：<code>/wb parasite infect|cure|list &lt;玩家&gt; [类型]</code>。",
      cuLead:"内置 4 种治疗剂。每种医治一组寄生虫且有其配方。右键治疗剂可治愈它所医治的一种寄生虫。",
      cuName:"治疗剂",cuTreats:"医治",cuRecipe:"配方（无序）",
      cuTip:"给予一份用于测试：<code>/wb give antiprotozoal_tonic</code>（还有 <code>deworming_paste</code>、<code>aquatic_remedy</code>、<code>broad_antiparasitic</code>）。全部可配置。",
      cmdLead:"基础指令 <code>/waterborne</code> — 别名 <code>/wb</code>、<code>/thirst</code>、<code>/sed</code>。",cmdPlayerT:"玩家",cmdAdminT:"管理",thCmd:"指令",thDesc:"作用",
      pc1:"打开你的状态界面（口渴、寄生虫、治疗）",pc2:"开关你的口渴条",pc3:"指令列表",pc4:"版本与作者",
      ac1:"管理玩家的口渴值",ac2:"管理寄生虫",ac3:"给予净化水或治疗剂",ac4:"重载配置与语言",
      permLead:"用 LuckPerms 或任意权限插件授予。",thPerm:"权限",thDefault:"默认",
      pp1:"受口渴与寄生虫影响（基础）",pp2:"免疫口渴与寄生虫",pp3:"全部管理指令（thirst、parasite、give、reload）",
      phLead:"需要 PlaceholderAPI。适合计分板或自定义 HUD（设为 <code>display.mode: NONE</code> 并自行绘制进度条）。",
      cfgLead:"一个干净、带注释的 <code>config.yml</code>。可添加你自己的寄生虫与治疗剂。",
      cfgSection:"部分",cfgWhat:"控制内容",
      cg1:"启用的世界与受影响的游戏模式",cg2:"上限、下降速率、炎热群系、按阈值的效果、归零伤害",cg3:"BOSSBAR / ACTIONBAR / NONE、颜色、格式",cg4:"每种水源恢复多少及是否为脏水",cg5:"脏生物群系、风险倍率、净化水配方",cg6:"感染几率、节奏、死亡清除、8 种寄生虫",cg7:"治疗剂：医治什么、其物品与配方",
      cfgThirstT:"口渴与显示",cfgParaT:"添加寄生虫",cfgCureT:"添加治疗剂",
      cfgNote:"编辑后运行 <code>/waterborne reload</code>。新配方会在启动/重载时注册；更改已有配方的材料需要重启。",
      reviewsTitle:"玩家评价",reviewsSub:"服主们对 Waterborne 的评价。",reviewsWord:"条评价",
      reviewWriteT:"写评价",reviewEditT:"编辑你的评价",reviewPublish:"发布评价",reviewUpdate:"更新评价",reviewPh:"分享你的体验…",
      reviewsLoginPrompt:"登录后即可留下评价。",reviewsNone:"暂无评价——来做第一个吧！",footMade:"由 infinity3113 制作 · Waterborne"}
  };
  var htmlKeys={ist1:1,ist2:1,ist3:1,ist4:1,instNote:1,cmdLead:1,phLead:1,cfgLead:1,thTip:1,waTip:1,waPurD:1,paTip:1,cuTip:1,th5b:1,wa3c:1,cfgNote:1};
  var saved=<?= isset($_GET['saved']) ? 'true':'false' ?>;

  // Instantánea del inglés inline: sirve de idioma EN y de respaldo para claves no traducidas.
  var EN={};
  document.querySelectorAll('[data-i18n]').forEach(function(el){var k=el.getAttribute('data-i18n');EN[k]=htmlKeys[k]?el.innerHTML:el.textContent;});
  document.querySelectorAll('[data-i18n-ph]').forEach(function(el){EN[el.getAttribute('data-i18n-ph')]=el.getAttribute('placeholder')||'';});

  function setLang(l){
    var d=(l==='en')?EN:(I18N[l]||{});
    document.querySelectorAll('[data-i18n]').forEach(function(el){
      var k=el.getAttribute('data-i18n'); var v=(d[k]!=null)?d[k]:EN[k]; if(v==null) return;
      if(htmlKeys[k]) el.innerHTML=v; else el.textContent=v;
    });
    document.querySelectorAll('[data-i18n-ph]').forEach(function(el){
      var k=el.getAttribute('data-i18n-ph'); var v=(d[k]!=null)?d[k]:EN[k]; if(v!=null) el.setAttribute('placeholder',v);
    });
    document.querySelectorAll('.langsw button').forEach(function(b){b.classList.toggle('on',b.getAttribute('data-lang')===l);});
    try{document.documentElement.lang=l;localStorage.setItem('lang',l);}catch(e){}
    document.cookie='lang='+l+';path=/;max-age=31536000';
  }
  document.querySelectorAll('.langsw button').forEach(function(b){
    b.addEventListener('click',function(){setLang(b.getAttribute('data-lang'));});
  });
  (function(){var s='en';try{s=localStorage.getItem('lang')||(document.cookie.match(/lang=(\w+)/)||[])[1]||'en';}catch(e){}
    if(s!=='en'&&!I18N[s])s='en';setLang(s);})();

  document.querySelectorAll('.sidenav a, [data-page]').forEach(function(a){
    a.addEventListener('click',function(e){
      var pg=a.getAttribute('data-page'); if(!pg)return; e.preventDefault();
      document.querySelectorAll('.sidenav a').forEach(function(x){x.classList.toggle('on',x.getAttribute('data-page')===pg);});
      document.querySelectorAll('.page').forEach(function(s){s.classList.toggle('active',s.getAttribute('data-p')===pg);});
      window.scrollTo({top:0,behavior:'smooth'});
    });
  });

  var sp=document.getElementById('starpick');
  if(sp){var ri=document.getElementById('rating');
    function paint(n){sp.querySelectorAll('span').forEach(function(s){s.classList.toggle('hot',parseInt(s.getAttribute('data-v'))<=n);});}
    paint(parseInt(ri.value)||0);
    sp.querySelectorAll('span').forEach(function(s){
      s.addEventListener('mouseenter',function(){paint(parseInt(s.getAttribute('data-v')));});
      s.addEventListener('click',function(){ri.value=s.getAttribute('data-v');paint(parseInt(ri.value));});
    });
    sp.addEventListener('mouseleave',function(){paint(parseInt(ri.value)||0);});
  }
  if(saved){document.querySelectorAll('.sidenav a').forEach(function(x){x.classList.toggle('on',x.getAttribute('data-page')==='reviews');});
    document.querySelectorAll('.page').forEach(function(s){s.classList.toggle('active',s.getAttribute('data-p')==='reviews');});}
})();
</script>
</body>
</html>
