<?php
require_once __DIR__ . '/includes/config.php';

$currentPage = 'word-count';
$pageTitle = 'Word Count Tool - Count Words Online | Vivora Tools';
$pageDescription = 'Use this free online word count tool to count words, characters, and lines instantly. Paste text or upload a .txt file with no sign-up.';
$canonicalPath = 'word-count';
$bodyClass = 'tool-page word-count-page';
$breadcrumbs = [
    ['name' => 'Home', 'url' => ''],
    ['name' => 'Word Count Tool', 'url' => 'word-count'],
];
$structuredData = [
    [
        '@context' => 'https://schema.org',
        '@type' => 'WebApplication',
        'name' => 'Word Count Tool',
        'url' => site_url('word-count'),
        'description' => $pageDescription,
        'applicationCategory' => 'UtilitiesApplication',
        'operatingSystem' => 'Any',
        'offers' => [
            '@type' => 'Offer',
            'price' => '0',
            'priceCurrency' => 'USD',
        ],
        'featureList' => [
            'Instant online word counter',
            'Character and line count',
            'Text file upload',
            'Copy text',
            'Reset text',
        ],
    ],
    [
        '@context' => 'https://schema.org',
        '@type' => 'FAQPage',
        'mainEntity' => [
            [
                '@type' => 'Question',
                'name' => 'How does the Word Count Tool count words?',
                'acceptedAnswer' => [
                    '@type' => 'Answer',
                    'text' => 'It counts groups of text separated by spaces, tabs, or line breaks as words.',
                ],
            ],
            [
                '@type' => 'Question',
                'name' => 'Is this online word counter free?',
                'acceptedAnswer' => [
                    '@type' => 'Answer',
                    'text' => 'Yes. Vivora Tools provides this word count tool for free, and you can use it without creating an account.',
                ],
            ],
            [
                '@type' => 'Question',
                'name' => 'Can I upload a text file for word count?',
                'acceptedAnswer' => [
                    '@type' => 'Answer',
                    'text' => 'Yes. Upload a .txt file and the tool will place the file content in the text area and count the words automatically.',
                ],
            ],
            [
                '@type' => 'Question',
                'name' => 'Do you store my text?',
                'acceptedAnswer' => [
                    '@type' => 'Answer',
                    'text' => 'No. The word count runs in your browser, and Vivora Tools does not store the text you type, paste, or upload.',
                ],
            ],
        ],
    ],
];
require __DIR__ . '/includes/head.php';
require __DIR__ . '/includes/header.php';
?>

<section class="tool-hero word-tool-hero">
  <div class="container">
    <div class="tool-hero-grid">
      <div>
        <nav class="tool-breadcrumb" aria-label="Breadcrumb">
          <a href="/">Home</a>
          <span>/</span>
          <span>Word Count Tool</span>
        </nav>
        <h1>Word Count Tool</h1>
        <p>
          Count words online with a fast, free word counter. Type, paste, or upload a text file to measure words, characters, and lines instantly.
        </p>
      </div>
      <div class="tool-result" aria-live="polite">
        <span class="tool-result-label">Words</span>
        <strong id="wordToolResult">0</strong>
        <span class="tool-result-unit">total words</span>
      </div>
    </div>
  </div>
</section>

<main class="section pt-0">
  <div class="container">
    <section class="string-tool-shell word-tool-shell" data-word-count-tool>
      <div class="string-tool-toolbar" aria-label="Word count actions">
        <label class="icon-action upload-action" for="wordFileInput" title="Upload .txt file">
          <i class="fa-solid fa-upload" aria-hidden="true"></i>
          <span>Upload .txt</span>
        </label>
        <input id="wordFileInput" class="sr-only" type="file" accept=".txt,text/plain" />
        <button class="icon-action" type="button" id="copyWordTextButton" title="Copy text">
          <i class="fa-solid fa-copy" aria-hidden="true"></i>
          <span>Copy</span>
        </button>
        <button class="icon-action danger" type="button" id="resetWordTextButton" title="Reset text">
          <i class="fa-solid fa-rotate-left" aria-hidden="true"></i>
          <span>Reset</span>
        </button>
      </div>

      <div class="string-tool-layout">
        <div class="string-input-panel">
          <label class="tool-label" for="wordInput">Your text</label>
          <textarea id="wordInput" class="string-textarea" rows="12" placeholder="Paste or type your text here..."></textarea>
          <div class="tool-meta-row">
            <span id="wordToolStatus">Ready to count words.</span>
            <span><strong id="wordCharacterResult">0</strong> characters</span>
          </div>
        </div>

        <aside class="string-stats-panel" aria-label="Text statistics">
          <div class="stat-tile primary">
            <span>Words</span>
            <strong id="wordToolMirror">0</strong>
          </div>
          <div class="stat-tile">
            <span>Characters</span>
            <strong id="wordCharacterMirror">0</strong>
          </div>
          <div class="stat-tile">
            <span>Lines</span>
            <strong id="wordLineResult">0</strong>
          </div>
          <button class="btn btn-primary calculate-btn" type="button" id="calculateWordButton">
            <i class="fa-solid fa-calculator" aria-hidden="true"></i>
            Calculate Word Count
          </button>
        </aside>
      </div>
    </section>

    <section class="tool-content-grid">
      <article>
        <h2>Free online word counter</h2>
        <p>
          This free word counter helps you measure article drafts, descriptions, essays, captions, and notes without signing in.
        </p>
      </article>
      <article>
        <h2>Useful for writing limits</h2>
        <p>
          Use the live count while editing text for forms, social posts, SEO summaries, assignments, and publishing platforms.
        </p>
      </article>
    </section>

    <section class="tool-seo-panel" aria-labelledby="wordCountGuideTitle">
      <div class="tool-seo-intro">
        <span class="tool-seo-kicker">Word counter guide</span>
        <h2 id="wordCountGuideTitle">How to use the Word Count Tool</h2>
        <p>
          Use this online word counter when you need to check writing length for blog posts, school assignments, SEO descriptions, captions, forms, or publishing limits.
        </p>
      </div>

      <div class="tool-steps">
        <article>
          <span>1</span>
          <h3>Add your text</h3>
          <p>Type directly, paste existing content, or upload a plain .txt file from your device.</p>
        </article>
        <article>
          <span>2</span>
          <h3>Review live counts</h3>
          <p>See words, characters, and lines update immediately while you write or edit.</p>
        </article>
        <article>
          <span>3</span>
          <h3>Copy or reset</h3>
          <p>Copy your text when finished, or reset the tool to start a fresh word count.</p>
        </article>
      </div>
    </section>

    <section class="tool-seo-panel" aria-labelledby="wordCountFaqTitle">
      <div class="tool-seo-intro">
        <span class="tool-seo-kicker">FAQs</span>
        <h2 id="wordCountFaqTitle">Word Count Tool FAQs</h2>
      </div>

      <div class="tool-faq-list">
        <article>
          <h3>How does the Word Count Tool count words?</h3>
          <p>It counts groups of text separated by spaces, tabs, or line breaks as words.</p>
        </article>
        <article>
          <h3>Is this online word counter free?</h3>
          <p>Yes. You can use the Vivora Tools word counter for free without creating an account.</p>
        </article>
        <article>
          <h3>Can I upload a text file?</h3>
          <p>Yes. Upload a .txt file and the tool will count the words in the file automatically.</p>
        </article>
        <article>
          <h3>Do you store my text?</h3>
          <p>No. The count runs in your browser, and Vivora Tools does not store your text.</p>
        </article>
      </div>
    </section>
  </div>
</main>

<?php require __DIR__ . '/includes/footer.php'; ?>
