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

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

$_pt = require __DIR__ . '/translations/korrespond-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>Korrespond User Guide — How to draft letters to Norwegian authorities</title>
    <meta name="description" content="Step-by-step guide to using Korrespond: choose a mode, select the right authority, set tone, describe your situation, and understand the output.">
    <meta name="robots" content="index, follow">
    <link rel="canonical" href="https://tools.dobetternorge.no/korrespond-guide.php">
    <meta property="og:title" content="Korrespond User Guide">
    <meta property="og:description" content="How to use Korrespond to draft letters, emails and court filings to Norwegian authorities.">
    <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">
</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="/korrespond.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="Korrespond documentation">
    <div class="kdoc-doc-nav__inner">
        <a href="/korrespond-about.php"><?= htmlspecialchars($t['nav_about']) ?></a>
        <a href="/korrespond-guide.php" class="is-active"><?= htmlspecialchars($t['nav_guide']) ?></a>
        <a href="/korrespond-tech.php"><?= htmlspecialchars($t['nav_howit']) ?></a>
        <?php if ($isAuthed): ?><a href="/korrespond.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/korrespond/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="#mode"><?= htmlspecialchars($t['toc_1']) ?></a></li>
            <li><a href="#body"><?= htmlspecialchars($t['toc_2']) ?></a></li>
            <li><a href="#output"><?= htmlspecialchars($t['toc_3']) ?></a></li>
            <li><a href="#tone"><?= htmlspecialchars($t['toc_4']) ?></a></li>
            <li><a href="#context"><?= htmlspecialchars($t['toc_5']) ?></a></li>
            <li><a href="#narrative"><?= htmlspecialchars($t['toc_6']) ?></a></li>
            <li><a href="#upload"><?= htmlspecialchars($t['toc_7']) ?></a></li>
            <li><a href="#clarify"><?= htmlspecialchars($t['toc_8']) ?></a></li>
            <li><a href="#output-result"><?= htmlspecialchars($t['toc_9']) ?></a></li>
            <li><a href="#refine"><?= htmlspecialchars($t['toc_10']) ?></a></li>
            <li><a href="#tips"><?= htmlspecialchars($t['toc_11']) ?></a></li>
        </ol>
    </div>

    <!-- Step 1: Mode -->
    <div class="kdoc-guide-step" id="mode">
        <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__screenshot">
            <img src="assets/images/korrespond/form-top.png" alt="Mode toggle showing Reply and Initiate options" class="kdoc-screenshot" style="max-width:700px;" loading="lazy">
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= $t['step1_p1_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= $t['step1_p2_html'] ?></p>
        </div>
    </div>

    <!-- Step 2: Recipient body -->
    <div class="kdoc-guide-step" id="body">
        <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_recipient']) ?></th>
                    <th><?= htmlspecialchars($t['th_statutes']) ?></th>
                    <th><?= htmlspecialchars($t['th_typical']) ?></th>
                </tr>
            </thead>
            <tbody>
                <tr><td>Barnehage</td><td>barnehageloven · fvl</td><td><?= htmlspecialchars($t['r1_use']) ?></td></tr>
                <tr><td>Skole (1.–10. trinn)</td><td>opplæringslova · fvl</td><td><?= htmlspecialchars($t['r2_use']) ?></td></tr>
                <tr><td>SFO</td><td>opplæringslova · fvl</td><td><?= htmlspecialchars($t['r3_use']) ?></td></tr>
                <tr><td>NAV</td><td>NAV-loven · fvl</td><td><?= htmlspecialchars($t['r4_use']) ?></td></tr>
                <tr><td>Bufdir</td><td>fvl · EMK Art. 8</td><td><?= htmlspecialchars($t['r5_use']) ?></td></tr>
                <tr><td>Barnevernet</td><td>barnevernsloven · fvl · EMK Art. 8</td><td><?= htmlspecialchars($t['r6_use']) ?></td></tr>
                <tr><td>Statsforvalteren</td><td>fvl · barnevernsloven</td><td><?= htmlspecialchars($t['r7_use']) ?></td></tr>
                <tr><td>Trygderetten</td><td>trygderettsloven · fvl</td><td><?= htmlspecialchars($t['r8_use']) ?></td></tr>
                <tr><td>Tingretten</td><td>tvisteloven · EMK Art. 6</td><td><?= htmlspecialchars($t['r9_use']) ?></td></tr>
                <tr><td>Kommune (annet)</td><td>fvl</td><td><?= htmlspecialchars($t['r10_use']) ?></td></tr>
                <tr><td>Annet</td><td>fvl (general)</td><td><?= htmlspecialchars($t['r11_use']) ?></td></tr>
            </tbody>
        </table>
    </div>

    <!-- Step 3: Output type -->
    <div class="kdoc-guide-step" id="output">
        <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_type']) ?></th><th><?= htmlspecialchars($t['th_when']) ?></th><th><?= htmlspecialchars($t['th_structure']) ?></th></tr>
            </thead>
            <tbody>
                <tr><td>Email</td><td><?= htmlspecialchars($t['ot1_when']) ?></td><td><?= htmlspecialchars($t['ot1_struct']) ?></td></tr>
                <tr><td>Formal letter</td><td><?= htmlspecialchars($t['ot2_when']) ?></td><td><?= htmlspecialchars($t['ot2_struct']) ?></td></tr>
                <tr><td>Court/tribunal filing</td><td><?= htmlspecialchars($t['ot3_when']) ?></td><td><?= htmlspecialchars($t['ot3_struct']) ?></td></tr>
                <tr><td>Phone-call prep</td><td><?= htmlspecialchars($t['ot4_when']) ?></td><td><?= htmlspecialchars($t['ot4_struct']) ?></td></tr>
            </tbody>
        </table>
    </div>

    <!-- Step 4: Tone -->
    <div class="kdoc-guide-step" id="tone">
        <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_tone']) ?></th><th><?= htmlspecialchars($t['th_when']) ?></th></tr>
            </thead>
            <tbody>
                <tr><td>Cooperative</td><td><?= htmlspecialchars($t['tone1_when']) ?></td></tr>
                <tr><td>Neutral-professional &#9733;</td><td><?= htmlspecialchars($t['tone2_when']) ?></td></tr>
                <tr><td>Firm</td><td><?= htmlspecialchars($t['tone3_when']) ?></td></tr>
                <tr><td>Adversarial</td><td><?= htmlspecialchars($t['tone4_when']) ?></td></tr>
                <tr><td>Conciliatory-warm</td><td><?= htmlspecialchars($t['tone5_when']) ?></td></tr>
            </tbody>
        </table>
    </div>

    <!-- Step 5: Context fields -->
    <div class="kdoc-guide-step" id="context">
        <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>
            <p style="margin-top:0.8rem;"><?= $t['step5_p3_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= $t['step5_p4_html'] ?></p>
        </div>
    </div>

    <!-- Step 6: Narrative + goal chips -->
    <div class="kdoc-guide-step" id="narrative">
        <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__screenshot">
            <img src="assets/images/korrespond/form-bottom.png" alt="Narrative field and goal chips" class="kdoc-screenshot" style="max-width:700px;" loading="lazy">
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= $t['step6_p1_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= $t['step6_p2_html'] ?></p>
            <ul style="margin-top:0.6rem; padding-left:1.4rem; font-size:0.9rem; line-height:1.8;">
                <li><?= $t['goal1_html'] ?></li>
                <li><?= $t['goal2_html'] ?></li>
                <li><?= $t['goal3_html'] ?></li>
                <li><?= $t['goal4_html'] ?></li>
                <li><?= $t['goal5_html'] ?></li>
                <li><?= $t['goal6_html'] ?></li>
                <li><?= $t['goal7_html'] ?></li>
            </ul>
            <p style="margin-top:0.8rem;"><?= htmlspecialchars($t['goal_note']) ?></p>
        </div>
    </div>

    <!-- Step 7: Upload -->
    <div class="kdoc-guide-step" id="upload">
        <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>
            <p style="margin-top:0.8rem;"><?= $t['step7_p3_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= htmlspecialchars($t['step7_p4']) ?></p>
        </div>
    </div>

    <!-- Step 8: Clarify gate -->
    <div class="kdoc-guide-step" id="clarify">
        <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>
            <p style="margin-top:0.8rem;"><?= $t['step8_p3_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= $t['step8_p4_html'] ?></p>
        </div>
    </div>

    <!-- Step 9: Understanding the output -->
    <div class="kdoc-guide-step" id="output-result">
        <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__screenshot">
            <img src="assets/images/korrespond/output-draft.png" alt="Two-column output: Norwegian bokmål and English side by side" class="kdoc-screenshot" style="max-width:800px;" loading="lazy">
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= htmlspecialchars($t['step9_intro']) ?></p>
            <ul style="padding-left:1.4rem; font-size:0.9rem; line-height:1.8; margin-top:0.5rem;">
                <li><?= $t['step9_col1_html'] ?></li>
                <li><?= $t['step9_col2_html'] ?></li>
            </ul>
            <p style="margin-top:0.8rem;"><?= $t['step9_note_html'] ?></p>
        </div>
    </div>

    <!-- Step 10: Refine -->
    <div class="kdoc-guide-step" id="refine">
        <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__screenshot">
            <img src="assets/images/korrespond/refine-panel.png" alt="Refine panel with Norwegian law, ECHR, and Both options" class="kdoc-screenshot" style="max-width:700px;" loading="lazy">
        </div>
        <div class="kdoc-guide-step__body">
            <p><?= $t['step10_p1_html'] ?></p>
            <p style="margin-top:0.8rem;"><?= htmlspecialchars($t['step10_scope']) ?></p>
            <ul style="padding-left:1.4rem; font-size:0.9rem; line-height:1.8; margin-top:0.5rem;">
                <li><?= $t['step10_opt1_html'] ?></li>
                <li><?= $t['step10_opt2_html'] ?></li>
                <li><?= $t['step10_opt3_html'] ?></li>
            </ul>
        </div>
        <div class="kdoc-guide-step__screenshot" style="margin-top:1rem;">
            <img src="assets/images/korrespond/output-refined.png" alt="Refined output with formal citations including opplæringslova and EMK" class="kdoc-screenshot" style="max-width:800px;" loading="lazy">
        </div>
    </div>

    <!-- Step 11: Tips -->
    <div class="kdoc-guide-step" id="tips">
        <div class="kdoc-guide-step__header">
            <span class="kdoc-guide-step__num">11</span>
            <h2 class="kdoc-guide-step__title"><?= htmlspecialchars($t['step11_title']) ?></h2>
        </div>
        <div class="kdoc-tips">
            <div class="kdoc-tip"><?= $t['tip1_html'] ?></div>
            <div class="kdoc-tip"><?= $t['tip2_html'] ?></div>
            <div class="kdoc-tip"><?= $t['tip3_html'] ?></div>
            <div class="kdoc-tip"><?= $t['tip4_html'] ?></div>
            <div class="kdoc-tip"><?= $t['tip5_html'] ?></div>
            <div class="kdoc-tip"><?= $t['tip6_html'] ?></div>
        </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="/korrespond.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="/korrespond-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>
