<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/bootstrap.php';

$uiLang   = dbnToolsCurrentLanguage();
$isAuthed = dbnToolsIsAuthenticated();
$langPath = '/redact-guide.php';
$toolsLogin  = 'https://dobetternorge.no/tools-login.php?return=' . urlencode('/redact.php');
$registerUrl = 'https://dobetternorge.no/register.php';

$_pt = require __DIR__ . '/translations/redact-guide.php';
$t   = $_pt[$uiLang] ?? $_pt['en'];
?>
<!doctype html>
<html lang="<?= htmlspecialchars($uiLang) ?>">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Redact User Guide — How to anonymise Norwegian legal documents</title>
    <meta name="description" content="Step-by-step guide to using Redact: choose an engine, set mode and region, configure entity types, add aliases, upload documents, and download the redacted Word file.">
    <meta name="robots" content="index, follow">
    <link rel="canonical" href="https://tools.dobetternorge.no/redact-guide.php">
    <meta property="og:title" content="Redact User Guide">
    <meta property="og:description" content="How to use Redact to anonymise Norwegian case notes, court decisions, and correspondence — contextual role tags, pseudonyms, Word export.">
    <meta name="theme-color" content="#00205B">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap">
    <link rel="stylesheet" href="assets/css/tools.css">
    <link rel="stylesheet" href="assets/css/dbn-tools-redesign.css">
</head>
<body class="kdoc-page">

<header class="lt-nav">
    <a href="https://dobetternorge.no" class="lt-nav__brand">
        <picture>
            <source srcset="assets/images/logo-header.webp" type="image/webp">
            <img class="lt-nav__logo" src="assets/images/logo-header.png" alt="Do Better Norge" width="140" height="36" loading="eager">
        </picture>
        <span class="lt-nav__badge">Legal Tools</span>
    </a>
    <div class="lt-nav__right">
        <nav class="shell-lang-switcher" aria-label="Language">
<?php foreach (dbnToolsSupportedLanguages() as $langCode): ?>
            <a href="<?= htmlspecialchars($langPath . '?lang=' . $langCode) ?>" class="<?= $langCode === $uiLang ? 'is-active' : '' ?>"><?= htmlspecialchars(dbnToolsLanguageLabel($langCode)) ?></a>
<?php endforeach; ?>
        </nav>
<?php if ($isAuthed): ?>
        <a href="/redact.php" class="lt-nav__cta lt-nav__cta--enter"><?= htmlspecialchars($t['nav_open']) ?></a>
<?php else: ?>
        <a href="<?= htmlspecialchars($toolsLogin) ?>" class="lt-nav__cta"><?= htmlspecialchars($t['nav_signin']) ?></a>
<?php endif; ?>
    </div>
</header>

<nav class="kdoc-doc-nav" aria-label="Redact documentation">
    <div class="kdoc-doc-nav__inner">
        <a href="/redact-about.php"><?= htmlspecialchars($t['nav_about']) ?></a>
        <a href="/redact-guide.php" class="is-active"><?= htmlspecialchars($t['nav_guide']) ?></a>
        <a href="/redact-tech.php"><?= htmlspecialchars($t['nav_howit']) ?></a>
        <?php if ($isAuthed): ?><a href="/redact.php"><?= htmlspecialchars($t['nav_opentool']) ?></a><?php endif; ?>
    </div>
</nav>

<!-- Hero -->
<section class="kdoc-hero" style="background: linear-gradient(rgba(0,20,60,0.78),rgba(0,20,60,0.86)), url('assets/images/redact/hero-guide.png') center/cover no-repeat;">
    <div class="kdoc-hero__inner">
        <p class="kdoc-hero__kicker"><?= htmlspecialchars($t['hero_kicker']) ?></p>
        <h1 class="kdoc-hero__title"><?= htmlspecialchars($t['hero_title']) ?></h1>
        <p class="kdoc-hero__sub"><?= htmlspecialchars($t['hero_sub']) ?></p>
    </div>
</section>

<!-- TOC + content -->
<div class="kdoc-section">

    <div class="kdoc-toc">
        <p class="kdoc-toc__title"><?= htmlspecialchars($t['toc_title']) ?></p>
        <ol>
            <li><a href="#engine"><?= htmlspecialchars($t['toc_1']) ?></a></li>
            <li><a href="#mode"><?= htmlspecialchars($t['toc_2']) ?></a></li>
            <li><a href="#region"><?= htmlspecialchars($t['toc_3']) ?></a></li>
            <li><a href="#entities"><?= htmlspecialchars($t['toc_4']) ?></a></li>
            <li><a href="#officials"><?= htmlspecialchars($t['toc_5']) ?></a></li>
            <li><a href="#output"><?= htmlspecialchars($t['toc_6']) ?></a></li>
            <li><a href="#exempt"><?= htmlspecialchars($t['toc_7']) ?></a></li>
            <li><a href="#aliases"><?= htmlspecialchars($t['toc_8']) ?></a></li>
            <li><a href="#upload"><?= htmlspecialchars($t['toc_9']) ?></a></li>
            <li><a href="#reading"><?= htmlspecialchars($t['toc_10']) ?></a></li>
        </ol>
    </div>

    <!-- Step 1: Engine -->
    <div class="kdoc-guide-step" id="engine">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">1</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step1_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= htmlspecialchars($t['step1_intro']) ?></p>
        </div>
        <table class="kdoc-table">
            <thead>
                <tr>
                    <th><?= htmlspecialchars($t['th_engine']) ?></th>
                    <th><?= htmlspecialchars($t['th_cost']) ?></th>
                    <th><?= htmlspecialchars($t['th_best']) ?></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Azure gpt-4o-mini &#9733;</td>
                    <td><?= htmlspecialchars($t['eng1_cost']) ?></td>
                    <td><?= htmlspecialchars($t['eng1_best']) ?></td>
                </tr>
                <tr>
                    <td>Azure gpt-4o</td>
                    <td><?= htmlspecialchars($t['eng2_cost']) ?></td>
                    <td><?= htmlspecialchars($t['eng2_best']) ?></td>
                </tr>
            </tbody>
        </table>
    </div>

    <!-- Step 2: Mode -->
    <div class="kdoc-guide-step" id="mode">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">2</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step2_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= htmlspecialchars($t['step2_intro']) ?></p>
        </div>
        <table class="kdoc-table">
            <thead>
                <tr>
                    <th><?= htmlspecialchars($t['th_mode']) ?></th>
                    <th><?= htmlspecialchars($t['th_does']) ?></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Standard &#9733;</td>
                    <td><?= htmlspecialchars($t['mode1_does']) ?></td>
                </tr>
                <tr>
                    <td>Strict</td>
                    <td><?= htmlspecialchars($t['mode2_does']) ?></td>
                </tr>
            </tbody>
        </table>
    </div>

    <!-- Step 3: Region -->
    <div class="kdoc-guide-step" id="region">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">3</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step3_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= htmlspecialchars($t['step3_intro']) ?></p>
        </div>
        <table class="kdoc-table">
            <thead>
                <tr>
                    <th><?= htmlspecialchars($t['th_region']) ?></th>
                    <th><?= htmlspecialchars($t['th_targets']) ?></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Nordic &#9733;</td>
                    <td><?= htmlspecialchars($t['reg1_targets']) ?></td>
                </tr>
                <tr>
                    <td>European</td>
                    <td><?= htmlspecialchars($t['reg2_targets']) ?></td>
                </tr>
                <tr>
                    <td>ECHR</td>
                    <td><?= htmlspecialchars($t['reg3_targets']) ?></td>
                </tr>
                <tr>
                    <td>Global</td>
                    <td><?= htmlspecialchars($t['reg4_targets']) ?></td>
                </tr>
            </tbody>
        </table>
    </div>

    <!-- Step 4: What to redact -->
    <div class="kdoc-guide-step" id="entities">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">4</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step4_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= htmlspecialchars($t['step4_intro']) ?></p>
        </div>
        <table class="kdoc-table">
            <thead>
                <tr>
                    <th><?= htmlspecialchars($t['th_entity']) ?></th>
                    <th><?= htmlspecialchars($t['th_entity_desc']) ?></th>
                </tr>
            </thead>
            <tbody>
                <tr><td>Names &#9733;</td><td><?= htmlspecialchars($t['ent1_desc']) ?></td></tr>
                <tr><td>Organisations &#9733;</td><td><?= htmlspecialchars($t['ent2_desc']) ?></td></tr>
                <tr><td>Places &#9733;</td><td><?= htmlspecialchars($t['ent3_desc']) ?></td></tr>
                <tr><td>Dates &#9733;</td><td><?= htmlspecialchars($t['ent4_desc']) ?></td></tr>
            </tbody>
        </table>
    </div>

    <!-- Step 5: Officials -->
    <div class="kdoc-guide-step" id="officials">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">5</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step5_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= $t['step5_p1_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= $t['step5_p2_html'] ?></p>
        </div>
    </div>

    <!-- Step 6: Output format -->
    <div class="kdoc-guide-step" id="output">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">6</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step6_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= htmlspecialchars($t['step6_intro']) ?></p>
        </div>
        <table class="kdoc-table">
            <thead>
                <tr>
                    <th><?= htmlspecialchars($t['th_format']) ?></th>
                    <th><?= htmlspecialchars($t['th_result']) ?></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Contextual tags &#9733;</td>
                    <td><?= htmlspecialchars($t['fmt1_result']) ?></td>
                </tr>
                <tr>
                    <td>Generic tags</td>
                    <td><?= htmlspecialchars($t['fmt2_result']) ?></td>
                </tr>
                <tr>
                    <td>Pseudonyms</td>
                    <td><?= htmlspecialchars($t['fmt3_result']) ?></td>
                </tr>
            </tbody>
        </table>
    </div>

    <!-- Step 7: Exempt names -->
    <div class="kdoc-guide-step" id="exempt">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">7</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step7_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= $t['step7_p1_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= $t['step7_p2_html'] ?></p>
        </div>
    </div>

    <!-- Step 8: Aliases -->
    <div class="kdoc-guide-step" id="aliases">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">8</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step8_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= $t['step8_p1_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= $t['step8_p2_html'] ?></p>
        </div>
    </div>

    <!-- Step 9: Upload -->
    <div class="kdoc-guide-step" id="upload">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">9</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step9_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= $t['step9_p1_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= $t['step9_p2_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= htmlspecialchars($t['step9_p3']) ?></p>
        </div>
    </div>

    <!-- Step 10: Reading & downloading -->
    <div class="kdoc-guide-step" id="reading">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">10</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step10_title']) ?></h2>
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= htmlspecialchars($t['step10_intro']) ?></p>
            <ul style="padding-left:1.4rem; font-size:0.9rem; line-height:1.8; margin-top:0.5rem;">
                <li><?= $t['dl1_html'] ?></li>
                <li><?= $t['dl2_html'] ?></li>
                <li><?= $t['dl3_html'] ?></li>
                <?php if (!empty($t['dl4_html'])): ?><li><?= $t['dl4_html'] ?></li><?php endif; ?>
            </ul>
        </div>
    </div>

</div><!-- /kdoc-section -->

<!-- CTA -->
<section class="kdoc-cta-strip">
    <h2 class="kdoc-cta-strip__title"><?= htmlspecialchars($t['cta_title']) ?></h2>
    <p class="kdoc-cta-strip__sub"><?= htmlspecialchars($t['cta_sub']) ?></p>
    <div class="kdoc-hero__ctas">
<?php if ($isAuthed): ?>
        <a href="/redact.php" class="kdoc-btn-primary"><?= htmlspecialchars($t['btn_open']) ?></a>
<?php else: ?>
        <a href="<?= htmlspecialchars($toolsLogin) ?>" class="kdoc-btn-primary"><?= htmlspecialchars($t['btn_signin_cta']) ?></a>
        <a href="<?= htmlspecialchars($registerUrl) ?>" class="kdoc-btn-secondary"><?= htmlspecialchars($t['btn_register']) ?></a>
<?php endif; ?>
        <a href="/redact-tech.php" class="kdoc-btn-secondary"><?= htmlspecialchars($t['btn_techlink']) ?></a>
    </div>
</section>

<?php require_once __DIR__ . '/includes/footer.php'; ?>
<script src="assets/js/tools.js" defer></script>
</body>
</html>
