/*
Theme Name: Collected Worlds
Theme URI: https://books.jabi.uk
Description: A dark, per-series codex theme built on Twenty Twenty-Five.
Author: Jim Hope
Template: twentytwentyfive
Version: 0.1.0
Requires at least: 6.5
Requires PHP: 8.0
Text Domain: collected-worlds
*/

/* -------------------------------------------------------------------------
 * Base
 * ---------------------------------------------------------------------- */

:root {
    --cw-bg: #0f1119;
    --cw-bg-light: #151827;
    --cw-surface: #1a1d2e;
    --cw-border: rgba(255, 255, 255, 0.09);
    --cw-text: #e2e4f0;
    --cw-muted: #9aa0b5;
    --cw-accent: var(--codex-accent, #e7c365);
    --cw-accent-dim: var(--codex-accent-dim, #8a6f00);
    --cw-heading: var(--codex-heading-font, "Crimson Pro", Georgia, serif);
    --cw-body: var(--codex-body-font, "Inter", system-ui, sans-serif);
}

html {
    background: var(--cw-bg);
}

body {
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(231, 195, 101, 0.06), transparent 60%),
        var(--cw-bg);
    color: var(--cw-text);
    font-family: var(--cw-body);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--cw-accent);
    text-underline-offset: 3px;
}

a:hover {
    color: var(--cw-accent);
    text-decoration-thickness: 2px;
}

::selection {
    background: var(--cw-accent);
    color: #0f1119;
}

/* -------------------------------------------------------------------------
 * Header / footer
 * ---------------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0.9rem 0;
    background: rgba(15, 17, 25, 0.86);
    border-bottom: 1px solid var(--cw-border);
    backdrop-filter: blur(12px);
}

.site-header .wp-block-site-title a {
    color: var(--cw-text);
    font-family: var(--cw-heading);
    font-size: 1.15rem;
    letter-spacing: 0.01em;
    text-decoration: none;
}

.site-nav {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.site-nav a {
    color: var(--cw-muted);
    text-decoration: none;
}

.site-nav a:hover {
    color: var(--cw-accent);
}

.site-footer {
    margin-top: 4rem;
    padding: 2rem 0;
    border-top: 1px solid var(--cw-border);
    color: var(--cw-muted);
    font-size: 0.85rem;
}

/* -------------------------------------------------------------------------
 * Codex layout
 * ---------------------------------------------------------------------- */

.codex-main {
    margin-top: 2rem;
}

.codex-layout {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    gap: 3rem;
    align-items: start;
}

.codex-sidebar {
    position: sticky;
    top: 5.5rem;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    padding-right: 0.5rem;
    font-size: 0.86rem;
    border-right: 1px solid var(--cw-border);
}

.codex-sidebar::-webkit-scrollbar {
    width: 6px;
}

.codex-sidebar::-webkit-scrollbar-thumb {
    background: var(--cw-border);
    border-radius: 3px;
}

/* -------------------------------------------------------------------------
 * Navigation
 * ---------------------------------------------------------------------- */

.codex-nav__series {
    display: block;
    margin: 0 0 1rem;
    color: var(--cw-accent);
    font-family: var(--cw-heading);
    font-size: 1.05rem;
    line-height: 1.3;
    text-decoration: none;
}

.codex-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.codex-nav__list .codex-nav__list {
    margin-left: 0.85rem;
    padding-left: 0.55rem;
    border-left: 1px solid var(--cw-border);
}

.codex-nav__item {
    position: relative;
    margin: 0.1rem 0;
}

.codex-nav__item > a {
    display: block;
    padding: 0.3rem 0.4rem;
    border-radius: 4px;
    color: var(--cw-muted);
    text-decoration: none;
    line-height: 1.35;
}

.codex-nav__item > a:hover {
    background: var(--cw-bg-light);
    color: var(--cw-text);
}

.codex-nav__item.is-current > a {
    background: color-mix(in srgb, var(--cw-accent) 14%, transparent);
    color: var(--cw-accent);
    font-weight: 600;
}

.codex-nav__item.is-ancestor > a {
    color: var(--cw-text);
}

.codex-nav__toggle {
    position: absolute;
    left: -0.95rem;
    top: 0.32rem;
    padding: 0;
    width: 1rem;
    height: 1rem;
    border: 0;
    background: transparent;
    color: var(--cw-muted);
    font-size: 0.65rem;
    line-height: 1;
    cursor: pointer;
}

.codex-nav__toggle:hover {
    color: var(--cw-accent);
}

/* Search */

.codex-search {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 1.1rem;
}

.codex-search__input {
    min-width: 0;
    flex: 1;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--cw-border);
    border-radius: 5px;
    background: var(--cw-bg-light);
    color: var(--cw-text);
    font-size: 0.82rem;
}

.codex-search__input::placeholder {
    color: var(--cw-muted);
}

.codex-search__submit {
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--cw-border);
    border-radius: 5px;
    background: var(--cw-surface);
    color: var(--cw-text);
    font-size: 0.75rem;
    cursor: pointer;
}

.codex-search__submit:hover {
    border-color: var(--cw-accent);
    color: var(--cw-accent);
}

/* -------------------------------------------------------------------------
 * Article
 * ---------------------------------------------------------------------- */

.codex-article .wp-block-post-title {
    margin: 0 0 1.75rem;
    color: var(--cw-accent);
    font-family: var(--cw-heading);
    font-size: clamp(2rem, 4vw, 2.9rem);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: 0.01em;
}

.codex-article .wp-block-post-content {
    font-size: 1.03rem;
    line-height: 1.78;
}

.codex-article h2,
.codex-article h3,
.codex-article h4 {
    color: var(--cw-accent-on-bg, var(--cw-text));
    font-family: var(--cw-heading);
    line-height: 1.25;
}

.codex-article h2 {
    margin: 2.6rem 0 0.9rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--cw-border);
    font-size: 1.5rem;
}

.codex-article h3 {
    margin: 1.9rem 0 0.6rem;
    font-size: 1.2rem;
}

.codex-article p {
    margin: 0 0 1.1rem;
}

.codex-article ul,
.codex-article ol {
    margin: 0 0 1.2rem;
    padding-left: 1.3rem;
}

.codex-article li {
    margin: 0.3rem 0;
}

.codex-article blockquote {
    margin: 1.6rem 0;
    padding: 0.2rem 0 0.2rem 1.2rem;
    border-left: 3px solid var(--cw-accent);
    color: var(--cw-muted);
    font-style: italic;
}

.codex-article blockquote p:last-child {
    margin-bottom: 0;
}

.codex-article table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.codex-article th,
.codex-article td {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--cw-border);
    text-align: left;
}

.codex-article th {
    background: var(--cw-bg-light);
    color: var(--cw-accent-on-bg, var(--cw-text));
}

.codex-link--missing {
    color: var(--cw-muted);
    border-bottom: 1px dotted var(--cw-muted);
    cursor: help;
}

/* -------------------------------------------------------------------------
 * Cards / children / backlinks
 * ---------------------------------------------------------------------- */

.codex-children {
    margin: 2rem 0;
}

.codex-children__heading {
    margin: 0 0 1rem;
    font-family: var(--codex-heading-font, var(--cw-heading));
    font-size: 1.35rem;
    line-height: 1.25;
}

.codex-children__grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    gap: 1rem !important;
}

.codex-card {
    padding: 1.1rem 1.2rem;
    border: 1px solid var(--codex-accent, var(--cw-border));
    border-radius: 8px;
    background: linear-gradient(180deg, var(--codex-bg-light, var(--cw-bg-light)), var(--codex-bg, var(--cw-bg)));
}

.codex-card__title {
    margin: 0 0 0.4rem;
    font-family: var(--codex-heading-font, var(--cw-heading));
    font-size: 1.05rem;
    line-height: 1.3;
}

.codex-card__title a {
    color: var(--codex-accent, var(--cw-accent));
    text-decoration: none;
}

.codex-card__excerpt {
    margin: 0;
    color: var(--cw-muted);
    font-size: 0.86rem;
    line-height: 1.55;
}

/* Series landing page: section cards */

.codex-browse__grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)) !important;
}

.codex-section-card {
    border-color: var(--codex-accent, var(--cw-border));
    background: linear-gradient(180deg, var(--codex-bg-light, var(--cw-bg-light)), var(--codex-bg, var(--cw-bg)));
}

.codex-section-card:hover,
.codex-section-card:focus-within {
    border-color: var(--cw-accent);
}

.codex-section-card__title {
    font-family: var(--codex-heading-font, var(--cw-heading));
}

.codex-section-card__title a {
    color: var(--codex-accent, var(--cw-accent));
}

.codex-section-card__description {
    color: var(--cw-muted);
}

.codex-section-card__count {
    color: var(--cw-muted);
    opacity: 0.8;
}

/* Breadcrumbs */

.codex-breadcrumbs {
    font-family: "Inter", system-ui, sans-serif;
    color: var(--codex-muted, var(--cw-muted));
}

.codex-breadcrumbs a {
    color: var(--cw-muted);
}

.codex-breadcrumbs a:hover {
    color: var(--cw-accent);
}

.codex-breadcrumbs .is-current {
    color: var(--cw-text);
    opacity: 0.7;
}

.codex-series__extra {
    padding-top: 0.5rem;
    border-top: 1px solid var(--cw-border);
}

.codex-backlinks {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--cw-border);
}

.codex-backlinks__title {
    margin: 0 0 0.6rem;
    color: var(--cw-muted);
    font-family: "Inter", system-ui, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.codex-backlinks ul {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.92rem;
}

/* -------------------------------------------------------------------------
 * Front page / archive
 * ---------------------------------------------------------------------- */

.codex-hero {
    padding: clamp(3rem, 8vw, 7rem) 0 2.5rem;
    text-align: center;
}

.codex-hero h1 {
    margin: 0 0 1rem;
    color: var(--cw-text);
    font-family: var(--cw-heading);
    font-size: clamp(2.6rem, 7vw, 5rem);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -0.01em;
}

.codex-hero p {
    max-width: 44rem;
    margin: 0 auto;
    color: var(--cw-muted);
    font-size: 1.1rem;
    line-height: 1.7;
}

.codex-archive-intro {
    margin: 3rem 0 1.5rem;
    text-align: center;
}

.codex-archive-intro h1 {
    margin: 0 0 0.5rem;
    font-family: var(--cw-heading);
    font-size: clamp(2rem, 4vw, 3rem);
}

.codex-archive-intro p {
    margin: 0 auto;
    max-width: 40rem;
    color: var(--cw-muted);
}

/* -------------------------------------------------------------------------
 * Homepage series sections
 * ---------------------------------------------------------------------- */

.codex-sections {
    padding: 3rem 0 1.5rem;
}

.codex-sections h2 {
    text-align: center;
    font-family: var(--cw-heading);
    color: var(--cw-text);
    margin-bottom: 3rem;
}

.codex-section {
    text-align: center;
}

/* Per-series accents on homepage sections */
.codex-section.series-batholomew-quill {
    --cw-accent: #e7c365;
    --cw-accent-dim: #8a6f00;
    --cw-accent-on-bg: #ffdf93;
    --cw-bg: #241a00;
    --cw-bg-light: #2a2008;
    --cw-heading: "Rock Salt", cursive;
    --cw-body: "Legend", "Inter", system-ui, sans-serif;
}

.codex-section.series-magitech-mysteries {
    --cw-accent: #cfbcff;
    --cw-accent-dim: #6750a4;
    --cw-accent-on-bg: #e0d2ff;
    --cw-bg: #1a1c2c;
    --cw-bg-light: #1e2032;
    --cw-heading: "Gemunu Libre", system-ui, sans-serif;
    --cw-body: "Legend", "Inter", system-ui, sans-serif;
}

.codex-section.series-the-case-files-of-the-dmc {
    --cw-accent: #ffb4ab;
    --cw-accent-dim: #93000a;
    --cw-accent-on-bg: #ffdad6;
    --cw-bg: #2e0005;
    --cw-bg-light: #380810;
    --cw-heading: "Bangers", system-ui, cursive;
    --cw-body: "Legend", "Inter", system-ui, sans-serif;
}

.codex-section .wp-block-post-thumbnail img {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--cw-border);
    background: var(--cw-bg-light);
}

.codex-section h3 {
    margin: 1rem 0 0.5rem;
    font-family: var(--cw-heading);
    color: var(--cw-accent);
}

.codex-section p {
    color: var(--cw-muted);
    font-size: 0.92rem;
    line-height: 1.55;
    margin-bottom: 1rem;
}

/* Buttons fill style on homepage sections */
.codex-sections .is-style-filled {
    margin-top: auto;
    width: 100%;
    text-align: center;
    background: var(--cw-accent);
    color: #0f1119;
    border: none;
}

.codex-sections .is-style-filled:hover {
    opacity: 0.9;
}

/* -------------------------------------------------------------------------
 * Series hub hero (cover image at top of series landing pages)
 * ---------------------------------------------------------------------- */

.codex-article .wp-block-post-featured-image {
    margin: 0 0 1.5rem;
    text-align: center;
}

.codex-article .wp-block-post-featured-image img {
    max-width: 220px;
    height: auto;
    border-radius: 50%;
    border: 3px solid var(--cw-border);
    background: var(--cw-bg-light);
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */

@media (max-width: 900px) {
    .codex-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .codex-sidebar {
        position: static;
        max-height: none;
        padding: 1rem 0 1.5rem;
        border-right: 0;
        border-bottom: 1px solid var(--cw-border);
    }

    .codex-sections {
        padding: 2rem 0 1rem;
    }

    .codex-sections h2 {
        margin-bottom: 2rem;
    }
}
