
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Changelog - EquestriCraft</title>
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link
        href="https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400;1,600&family=Inter:wght@300;400;500&family=JetBrains+Mono:wght@400;500&display=swap"
        rel="stylesheet">

    <style>
        :root {
            --darkbrown: #35281E;
            --lightbrown: #725F54;
            --offwhite: #FBF7F5;
            --darkoffwhite: #EFEAE9;
            --midtone: #D9D3D0;
        }

        * {
            box-sizing: border-box;
            font-family: Inter, Arial, sans-serif;
            overflow-wrap: break-word;
        }

        body {
            min-height: 100vh;
            margin: 0;
            background: linear-gradient(var(--darkoffwhite), var(--offwhite));
        }

        /* -- HEADER -- */

        header {
            padding: 3rem 2rem 0;
            text-align: center;
            background: rgba(242, 236, 236, .6) url(images/changelog-banner.png) center / cover no-repeat;
            background-blend-mode: lighten;
            border-bottom: 3px solid var(--darkbrown);
        }

        header span {
            font-family: Lora, serif;
            font-size: clamp(2rem, 5vw, 5.5rem);
            line-height: 1.1;
            color: var(--darkbrown);
        }

        #title-brand {
            font-style: italic;
        }

        header p {
            width: fit-content;
            max-width: 100%;
            margin: 1rem auto;
            padding: 1rem 2rem;
            color: white;
            font-weight: 500;
            text-shadow: 0 0 15px var(--darkbrown);
        }

        /* -- MAIN LAYOUT -- */

        main {
            display: flex;
            flex-direction: column;
            max-width: 1000px;
            margin: 2rem auto;
        }

        main>* {
            margin: 1rem;
            padding: 1.5rem;
        }

        main>a {
            align-self: flex-start;
            margin-left: .7rem;
            padding: .75rem 1.75rem 1rem 1.5rem;
            border-radius: 3rem;
            background: var(--darkbrown);
            color: white;
            text-decoration: none;
            transition: .3s;
        }

        main>a:hover, main>a:active {
            background: var(--lightbrown);
        }

        .content-area, #changelog-container {
            margin: 0;
            padding: 0;
        }

        /* -- SEARCH BAR -- */

        #search {
            display: flex;
            align-items: center;
            padding: 0 1.5rem;
        }

        .form {
            flex: 1 1 0%;
            min-width: 0;
            padding: .4rem 1rem .5rem;
            border: 3px solid var(--lightbrown);
            border-radius: 3rem;
            background: var(--darkoffwhite);
            transition: background-color .5s, border-color .5s;
        }

        .form:focus-within {
            background: var(--offwhite);
            border-color: var(--darkbrown);
        }

        .form label {
            display: flex;
            align-items: center;
            gap: .6rem;
        }

        .form input {
            flex: 1;
            min-width: 0;
            padding: 0;
            border: none;
            outline: none;
            background: none;
            box-shadow: none;
            color: var(--darkbrown);
            font-size: 1rem;
        }

        .form input::placeholder {
            color: var(--lightbrown);
            opacity: 1;
        }

        .form .icon, .form .close-button {
            display: flex;
            align-items: center;
            transition: opacity .5s, visibility .5s;
        }

        .form .icon {
            opacity: 1;
            visibility: visible;
        }

        .form .icon svg {
            display: block;
            width: 18px;
            height: 18px;
            color: var(--lightbrown);
        }

        .form .close-button {
            padding: 0;
            border: none;
            background: none;
            cursor: pointer;
            opacity: 0;
            visibility: hidden;
        }

        .form .close-button svg {
            display: block;
            width: 16px;
            height: 16px;
            fill: var(--lightbrown);
        }

        .form:focus-within .icon {
            opacity: 0;
            visibility: hidden;
        }

        .form:focus-within .close-button {
            opacity: 1;
            visibility: visible;
        }

        /* -- CHANGELOG ENTRIES -- */

        #changelog-container {
            display: flex;
            flex-direction: column;
        }

        #changelog-container>* {
            margin: 1rem;
            padding: 1.5rem;
            background: var(--midtone);
        }

        .version-label {
            font: bolder 2rem Lora, serif;
            color: var(--darkbrown);
        }

        .version-date {
            margin-left: .5rem;
            font: .8rem JetBrains Mono, monospace;
            color: var(--lightbrown);
        }

        .category-group {
            margin-top: 2rem;
            padding: 1rem;
            border: 3px solid var(--lightbrown);
            border-radius: 0 2rem;
        }

        .category-header {
            position: relative;
        }

        .category-label {
            position: absolute;
            top: -28px;
            outline: 5px solid var(--midtone);
            background: var(--midtone);
            color: var(--lightbrown);
            font: bolder 1rem JetBrains Mono, monospace;
            text-transform: uppercase;
        }

        .item-category-tag {
            display: none;
        }

        .item-main {
            max-width: 700px;
            margin: 1rem 0;
        }

        .item-name {
            color: var(--darkbrown);
            font-size: 1.2rem;
            font-weight: bold;
        }

        .item-description {
            color: var(--lightbrown);
            font-size: .9rem;
        }

        .item-description>p {
            margin: .5rem auto 0 1rem;
        }

        /* -- EMPTY STATE -- */

        .empty-state {
            background: var(--midtone);
            color: var(--darkbrown);
            text-align: center;
        }

        /* -- RESPONSIVE -- */

        @media (max-width: 450px) {
            main>a {
                align-self: center;
                font-size: .9rem;
            }
        }
    </style>
</head>

<body>
    <header>
        <h1>
            <span id="title-brand">EquestriCraft </span>
            <span id="title-suffix">Changelog</span>
        </h1>
        <p>Released features and bug fixes</p>
    </header>

    <main>
        <a href="https://equestricraftmc.com">&#8617; &nbsp; Take me back to the homepage</a>

        <!-- SEARCH -->
        
        <form id="search" method="get" action="/changelog">
            <div class="form">
                <label for="search-input">
                    <div class="icon">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
                            xmlns="http://www.w3.org/2000/svg">
                            <path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
                                stroke-linecap="round" stroke-linejoin="round" />
                        </svg>
                    </div>

                    <input id="search-input" name="text" type="text"
                        placeholder="Search the changelog" autocomplete="off"
                        value="">

                    <button type="button" class="close-button" aria-label="Clear search">
                        <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
                            <path
                                d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
                                fill-rule="evenodd" clip-rule="evenodd" />
                        </svg>
                    </button>
                </label>
            </div>
        </form>

        <!-- CHANGELOG CONTENT -->

        <div class="content-area">
            
        </div>

        <div class="empty-state">
            Nothing to show.
        </div>
    </main>

    <script>
        const searchForm = document.querySelector('#search');
        const searchInput = document.querySelector('#search-input');
        const clearButton = document.querySelector('.close-button');

        // -- CLEAR SEARCH --

        clearButton.addEventListener('click', () => {
            searchInput.value = '';
            searchForm.requestSubmit();
        });

        // -- SEARCH HIGHLIGHTING --

        const searchTerm = new URLSearchParams(window.location.search).get('text')
            || searchInput?.value || '';

        if (searchTerm.trim()) {
            const terms = searchTerm.trim().split(/\s+/)
                .map(term => term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
                .sort((a, b) => b.length - a.length);

            const regex = new RegExp(`(${terms.join('|')})`, 'giu');

            document.querySelectorAll('.item-name, .item-description').forEach(element => {
                const walker = document.createTreeWalker(
                    element,
                    NodeFilter.SHOW_TEXT,
                    {
                        acceptNode: node =>
                            node.parentElement.closest('mark, script, style')
                                ? NodeFilter.FILTER_REJECT
                                : NodeFilter.FILTER_ACCEPT
                    }
                );

                const textNodes = [];

                while (walker.nextNode()) {
                    textNodes.push(walker.currentNode);
                }

                textNodes.forEach(node => {
                    const matches = [...node.textContent.matchAll(regex)];
                    if (!matches.length) return;

                    const fragment = document.createDocumentFragment();
                    let lastIndex = 0;

                    matches.forEach(match => {
                        fragment.append(node.textContent.slice(lastIndex, match.index));

                        const highlight = document.createElement('mark');
                        highlight.className = 'search-highlight';
                        highlight.textContent = match[0];
                        fragment.append(highlight);

                        lastIndex = match.index + match[0].length;
                    });

                    fragment.append(node.textContent.slice(lastIndex));
                    node.replaceWith(fragment);
                });
            });
        }
    </script>
</body>

</html>
