/* ==========================================================================
   NOT-WIKIPEDIA SHARED STYLES
   An encyclopedia of hallucinations, lost history, and abstract concepts
   ========================================================================== */

/* RESET & BASICS */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 2em 0;
    background-color: #f6f6f6;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: #202122;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: #0645ad;
    background: none;
    transition: color 0.2s ease;
}

a:visited {
    color: #0b0080;
}

a:hover {
    text-decoration: underline;
    color: #3366cc;
}

/* Internal links to existing pages */
a.internal-link {
    color: #0645ad;
}

/* Links to non-existent pages (red links) */
a.redlink {
    color: #ba0000;
}

/* LAYOUT GRID */
.container {
    position: relative;
    min-height: 100vh;
}

/* MAIN CONTENT */
#content {
    max-width: 900px;
    margin: 0 auto;
    background-color: #ffffff;
    padding: 2.5em 3em 3em 3em;
    min-height: calc(100vh - 4em);
    box-shadow: 0 0 1px rgba(0,0,0,0.1);
}

h1#firstHeading {
    margin-bottom: 0.5em;
    padding-bottom: 0.4em;
    font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
    font-size: 2.2em;
    line-height: 1.3;
    border-bottom: 1px solid #a2a9b1;
    font-weight: 400;
}

#siteSub {
    font-size: 92%;
    margin-bottom: 0.5em;
    color: #54595d;
}

#contentSub {
    font-size: 84%;
    line-height: 1.2em;
    margin: 0 0 1.4em;
    color: #54595d;
}

/* ARTICLE BODY */
p {
    margin: 0.75em 0 1.25em 0;
    line-height: 1.7;
}

ul, ol {
    margin: 0.75em 0 1.25em 0;
    padding-left: 2em;
}

li {
    margin-bottom: 0.4em;
}

h2 {
    font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
    font-weight: 400;
    font-size: 1.6em;
    margin: 1.5em 0 0.5em 0;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #a2a9b1;
}

h3 {
    font-weight: bold;
    font-size: 1.2em;
    margin: 0.8em 0 0.3em 0;
}

h4 {
    font-weight: bold;
    font-size: 1em;
    margin: 0.6em 0 0.2em 0;
}

.mw-editsection {
    font-size: small;
    font-family: sans-serif;
    margin-left: 1em;
    vertical-align: baseline;
    line-height: 1em;
}

/* INFOBOX - Base styles, color set per-article via inline style */
.infobox {
    border: 1px solid #a2a9b1;
    border-spacing: 3px;
    background-color: #f8f9fa;
    color: black;
    margin: 0.5em 0 0.5em 1em;
    padding: 0.2em;
    float: right;
    clear: right;
    font-size: 88%;
    line-height: 1.5em;
    width: 22em;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.infobox th {
    vertical-align: top;
    text-align: left;
    padding: 0.2em 0.4em;
}

.infobox td {
    vertical-align: top;
    padding: 0.2em 0.4em;
}

.infobox-title {
    font-size: 125%;
    font-weight: bold;
    text-align: center;
    padding: 0.2em;
    background-color: #b0c4de; /* Default, override per article */
}

.infobox-image {
    text-align: center;
    padding: 10px 0;
}

.infobox-caption {
    font-size: 90%;
    font-style: italic;
    padding: 4px;
}

/* TOC */
#toc {
    background-color: #f8f9fa;
    border: 1px solid #a2a9b1;
    padding: 12px;
    font-size: 95%;
    display: inline-block;
    min-width: 200px;
    border-radius: 2px;
    margin: 1em 0;
}

#toc h2 {
    display: inline;
    border: none;
    padding: 0;
    font-size: 100%;
    font-weight: bold;
    font-family: sans-serif;
}

#toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#toc li {
    margin-bottom: 2px;
}

#toc .tocnumber {
    color: #202122;
    padding-right: 0.5em;
}

/* REFERENCES */
.reflist {
    font-size: 90%;
    margin-bottom: 0.5em;
    list-style-type: decimal;
    padding-left: 2em;
}

/* NOTICES / AMBOX */
.ambox {
    border: 1px solid #a2a9b1;
    border-left: 10px solid #f28500;
    background: #fbfbfb;
    margin: 0 0 1.5em 0;
    padding: 0.75em 1em;
    font-size: 90%;
    border-radius: 2px;
}

.ambox-notice { border-left-color: #1e90ff; }
.ambox-warning { border-left-color: #f28500; }
.ambox-serious { border-left-color: #b22222; }
.ambox-merge { border-left-color: #9932cc; }
.ambox-style { border-left-color: #808080; }

/* BLOCKQUOTE */
blockquote {
    margin: 1em 2em;
    padding-left: 1em;
    border-left: 3px solid #a2a9b1;
    font-style: italic;
    color: #54595d;
}

/* TABLES */
.wikitable {
    border-collapse: collapse;
    margin: 1em 0;
    background-color: #f8f9fa;
}

.wikitable th, .wikitable td {
    border: 1px solid #a2a9b1;
    padding: 0.4em 0.6em;
}

.wikitable th {
    background-color: #eaecf0;
    text-align: left;
}

/* HATNOTE */
.hatnote {
    font-style: italic;
    padding-left: 1.6em;
    margin-bottom: 0.5em;
}

/* NAVIGATION */
#wiki-nav {
    max-width: 900px;
    margin: 0 auto 1em auto;
    padding: 0.5em 1em;
    font-size: 90%;
    color: #54595d;
}

#wiki-nav a {
    margin: 0 0.5em;
}

/* CATEGORIES */
#catlinks {
    margin-top: 2em;
    padding: 0.5em;
    background-color: #f8f9fa;
    border: 1px solid #a2a9b1;
    font-size: 90%;
}

/* EQUATIONS */
.equation {
    text-align: center;
    font-family: 'Times New Roman', serif;
    font-size: 1.1em;
    margin: 1em 0;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1024px) {
    #content {
        max-width: 95%;
        padding: 2em;
    }

    .infobox {
        width: 20em;
    }
}

@media (max-width: 768px) {
    #content {
        padding: 1.5em;
        max-width: 100%;
    }

    .infobox {
        float: none;
        width: 100%;
        margin: 1.5em 0;
    }

    h1#firstHeading {
        font-size: 1.6em;
    }

    #toc {
        width: 100%;
    }

    .ambox {
        margin: 0 0 1em 0;
    }

    .wikitable {
        font-size: 90%;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    #content {
        padding: 1em;
    }

    h1#firstHeading {
        font-size: 1.4em;
    }

    h2 {
        font-size: 1.3em;
    }
}

/* ==========================================================================
   HTMX INTERACTIVE COMPONENTS
   ========================================================================== */

/* WIKI HEADER / NAVIGATION */
.wiki-header {
    max-width: 900px;
    margin: 0 auto 1em auto;
    padding: 0.75em 1em;
    background: #fff;
    border-bottom: 1px solid #a2a9b1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1em;
    flex-wrap: wrap;
}

.wiki-header-left {
    display: flex;
    align-items: center;
    gap: 1em;
}

.wiki-logo {
    font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
    font-size: 1.3em;
    font-weight: 400;
    color: #202122;
    text-decoration: none;
}

.wiki-logo:hover {
    text-decoration: none;
    color: #0645ad;
}

/* SEARCH COMPONENT */
.search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 200px;
}

#wiki-search {
    width: 100%;
    padding: 0.5em 0.75em;
    border: 1px solid #a2a9b1;
    border-radius: 2px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#wiki-search:focus {
    outline: none;
    border-color: #3366cc;
    box-shadow: 0 0 0 2px rgba(51, 102, 204, 0.2);
}

#wiki-search::placeholder {
    color: #72777d;
}

/* SEARCH RESULTS DROPDOWN */
#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #a2a9b1;
    border-top: none;
    border-radius: 0 0 2px 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

#search-results.active {
    display: block;
}

.search-results-header {
    padding: 0.5em 0.75em;
    font-size: 12px;
    color: #72777d;
    background: #f8f9fa;
    border-bottom: 1px solid #eaecf0;
}

.search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-result-item {
    padding: 0.5em 0.75em;
    border-bottom: 1px solid #eaecf0;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-link {
    display: flex;
    align-items: center;
    gap: 0.5em;
    text-decoration: none;
}

.search-result-title {
    font-weight: 500;
    color: #0645ad;
}

.search-result-summary {
    margin: 0.25em 0 0 0;
    font-size: 12px;
    color: #54595d;
    line-height: 1.4;
}

.search-result-summary mark {
    background: #fff3cd;
    padding: 0 2px;
}

.search-no-results,
.search-loading,
.search-error {
    padding: 1em;
    text-align: center;
    color: #72777d;
    font-size: 14px;
}

.search-error {
    color: #d33;
}

/* TYPE BADGES */
.type-badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    font-size: 11px;
    font-weight: 500;
    border-radius: 2px;
    background: #eaecf0;
    color: #54595d;
    text-transform: lowercase;
}

.type-phenomenon { background: #fff3cd; color: #856404; }
.type-theory { background: #d4edda; color: #155724; }
.type-methodology { background: #cce5ff; color: #004085; }
.type-practice { background: #e2d5f1; color: #5a3d8a; }
.type-field { background: #d1ecf1; color: #0c5460; }
.type-institution { background: #f8d7da; color: #721c24; }
.type-event { background: #ffeeba; color: #856404; }
.type-person { background: #c3e6cb; color: #155724; }
.type-article { background: #eaecf0; color: #54595d; }

.category-tag {
    font-size: 11px;
    color: #72777d;
    margin-left: 0.5em;
}

/* PREVIEW POPOVER */
.preview-popover {
    position: absolute;
    z-index: 2000;
    background: #fff;
    border: 1px solid #a2a9b1;
    border-radius: 2px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    max-width: 350px;
    padding: 1em;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.preview-card h4 {
    margin: 0 0 0.5em 0;
    font-size: 1.1em;
    font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
}

.preview-card h4 a {
    color: #0645ad;
    text-decoration: none;
}

.preview-card h4 a:hover {
    text-decoration: underline;
}

.preview-card p {
    margin: 0.5em 0;
    font-size: 13px;
    color: #54595d;
    line-height: 1.5;
}

.preview-meta {
    margin: 0.75em 0 0 0;
    padding: 0.5em;
    background: #f8f9fa;
    border-radius: 2px;
    font-size: 12px;
}

.preview-meta dt {
    float: left;
    clear: left;
    width: 80px;
    font-weight: 500;
    color: #54595d;
}

.preview-meta dd {
    margin-left: 85px;
    margin-bottom: 0.25em;
    color: #202122;
}

/* NAVIGATION BUTTONS */
.wiki-nav-buttons {
    display: flex;
    gap: 0.5em;
}

.wiki-nav-btn {
    padding: 0.4em 0.75em;
    border: 1px solid #a2a9b1;
    border-radius: 2px;
    background: #f8f9fa;
    color: #202122;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.wiki-nav-btn:hover {
    background: #eaecf0;
    border-color: #72777d;
    text-decoration: none;
}

/* CATEGORY TABS */
.category-tabs {
    display: flex;
    gap: 0.25em;
    margin: 1em 0;
    border-bottom: 1px solid #a2a9b1;
    padding-bottom: 0;
}

.category-tabs a {
    padding: 0.5em 1em;
    text-decoration: none;
    color: #0645ad;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 2px 2px 0 0;
    margin-bottom: -1px;
    background: transparent;
}

.category-tabs a:hover {
    background: #f8f9fa;
    text-decoration: none;
}

.category-tabs a.active {
    background: #fff;
    border-color: #a2a9b1;
    color: #202122;
    font-weight: 500;
}

/* ARTICLE LIST (categories/all pages) */
.article-list {
    list-style: none;
    padding: 0;
    margin: 0;
    columns: 2;
    column-gap: 2em;
}

.article-list li {
    margin-bottom: 0.5em;
    break-inside: avoid;
}

.article-list a {
    text-decoration: none;
}

.article-list a:hover {
    text-decoration: underline;
}

/* HTMX LOADING STATES */
.htmx-request {
    opacity: 0.7;
    pointer-events: none;
}

.htmx-request::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #a2a9b1;
    border-top-color: #3366cc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* RESPONSIVE ADJUSTMENTS FOR NEW COMPONENTS */
@media (max-width: 768px) {
    .wiki-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-container {
        max-width: none;
        order: -1;
    }

    .wiki-nav-buttons {
        justify-content: center;
    }

    .article-list {
        columns: 1;
    }

    .preview-popover {
        max-width: calc(100vw - 40px);
        left: 20px !important;
        right: 20px;
    }
}

@media (max-width: 480px) {
    .wiki-header-left {
        justify-content: center;
    }

    .wiki-logo {
        font-size: 1.1em;
    }

    #wiki-search {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .category-tabs {
        flex-wrap: wrap;
    }

    .category-tabs a {
        flex: 1;
        text-align: center;
        min-width: 80px;
    }
}
