/*
Theme Name: Historias
Theme URI: https://example.com/historias
Author: Ali
Description: A text-first theme in light and dark for an erotic short-story site. Stories are listed as a reading queue rather than a media grid, with categories, series, author profiles, reader ratings and per-country tagging.
Version: 1.9
License: GNU General Public License v2 or later
Text Domain: historias
Domain Path: /languages
Tags: dark, blog, custom-colors, translation-ready
*/

/* =============================================================
 *  Design system
 *
 *  Two decisions carry the whole look:
 *
 *  1. Nothing is rounded. Not a card, not a button, not an avatar.
 *     A single stray border-radius reads as a mistake here, so radius
 *     is never set anywhere below.
 *
 *  2. The page is a column of text, not a grid of pictures. Cards are
 *     separated by a coloured left rule and generous vertical rhythm
 *     rather than by borders or panels.
 * ============================================================= */

:root {
    /* Surfaces - a cool, slightly blue-shifted dark */
    --bg:            #0f172a;
    --bg-soft:       #1e293b;
    --bg-softer:     #273449;
    --border:        #1e293b;
    --border-strong: #334155;

    /* Text */
    --text:          #94a3b8;
    --text-strong:   #ffffff;
    --text-muted:    #64748b;

    /* Accent - indigo, used for every category, link and marker */
    --accent:        #6366f1;
    --accent-hover:  #818cf8;
    --accent-soft:   #312e81;
    --accent-text:   #a5b4fc;
    --accent-line:   #4338ca;

    /* Meaningful colours */
    --premium:       #eab308;
    --star:          #facc15;

    /* Surfaces and text that used to be written out in place */
    --header-bg:     rgba(15, 23, 42, .92);
    --overlay-bg:    rgba(8, 13, 26, .97);
    --footer-fade:   #0d1424;
    --fade-from:     rgba(15, 23, 42, 0);
    --prose:         #cbd5e1;
    --prose-em:      #e2e8f0;
    --chip-hover:    #c7d2fe;
    --premium-soft:  #422006;

    /* Danger - deleting an account, taking a story down */
    --danger:        #ef4444;
    --danger-text:   #f87171;
    --danger-bg:     rgba(239, 68, 68, .12);
    --danger-border: rgba(239, 68, 68, .35);
    --notice-bg:     rgba(99, 102, 241, .12);

    color-scheme: dark;

    /* The height of a header control. The field and the icon button both
       read from it, so they stay the same size by construction. */
    --control-h: 44px;

    --container: 1120px;
    --gutter: 16px;

    --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 18px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--accent-hover);
    text-decoration: none;
    transition: color .15s;
}

a:hover {
    color: var(--text-strong);
}

h1, h2, h3, h4 {
    color: var(--text-strong);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 16px;
}

h1 { font-size: 45px; }
h2 { font-size: 34px; }
h3 { font-size: 25px; }
h4 { font-size: 20px; }

p { margin: 0 0 16px; }

::selection {
    background: var(--accent-soft);
    color: #fff;
}

/* Focus is visible, and square like everything else */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent-hover);
    outline-offset: 2px;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* =============================================================
 *  Header
 * ============================================================= */

.site-header {
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--header-bg);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 64px;
}

.site-logo {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-strong);
    white-space: nowrap;
}

.site-logo:hover { color: var(--text-strong); }
.site-logo .logo-accent { color: var(--accent-hover); }

.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.header-nav a {
    padding: 8px 12px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
}

.header-nav a:hover,
.header-nav a.is-current {
    color: var(--text-strong);
    background: var(--bg-soft);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--control-h);
    height: var(--control-h);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: color .15s, background .15s;
}

.icon-btn:hover {
    color: var(--text-strong);
    background: var(--bg-soft);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Mobile menu toggle is hidden until the layout narrows */
.menu-toggle { display: none; }

/* =============================================================
 *  Buttons
 * ============================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-ghost:hover {
    border-color: var(--accent-hover);
    color: var(--text-strong);
}

.btn-block { width: 100%; }

/* =============================================================
 *  Hero
 * ============================================================= */

.hero {
    padding: 56px 0 44px;
    text-align: center;
}

.hero-banner {
    display: block;
    margin-bottom: 28px;
    padding: 10px 16px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 16px;
    font-weight: 600;
}

.hero-banner:hover {
    background: var(--accent-line);
    color: #fff;
}

.hero h1 {
    font-size: 63px;
    margin-bottom: 16px;
}

.hero-lead {
    max-width: 620px;
    margin: 0 auto 28px;
    font-size: 19px;
    color: var(--text);
}

/* --- Search --- */

.hero-search {
    display: flex;
    max-width: 560px;
    margin: 0 auto;
}

.hero-search input {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
    border-right: 0;
    color: var(--text-strong);
    font-family: inherit;
    font-size: 17px;
}

.hero-search input::placeholder { color: var(--text-muted); }

.hero-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.hero-search button {
    padding: 12px 22px;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
}

.hero-search button:hover { background: var(--accent-hover); }

/* =============================================================
 *  Category grid
 * ============================================================= */

.section-heading {
    margin: 56px 0 24px;
    font-size: 34px;
}

.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.2;
}

.category-chip:hover {
    background: var(--accent-line);
    color: #fff;
}

.category-chip .chip-emoji {
    font-size: 17px;
    line-height: 1;
}

.category-chip .chip-count {
    color: var(--accent-hover);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.category-chip:hover .chip-count { color: var(--chip-hover); }

/* =============================================================
 *  Story list
 *
 *  The left rule is the card. No panel, no border box - the rule plus
 *  the space around it is what separates one story from the next.
 * ============================================================= */

.story-list {
    margin-top: 8px;
}

.story-card {
    margin-bottom: 40px;
    padding-left: 16px;
    border-left: 4px solid var(--accent-line);
}

.story-card:hover {
    border-left-color: var(--accent-hover);
}

.story-meta-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

/* Small square category label, sitting above the title */
.tag-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 16px;
    font-weight: 500;
    text-transform: lowercase;
}

.tag-pill:hover {
    background: var(--accent-line);
    color: #fff;
}

.pill-premium {
    background: var(--premium-soft);
    color: var(--premium);
    text-transform: uppercase;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
}

.story-title {
    margin: 0 0 8px;
    font-size: 27px;
    font-weight: 800;
    line-height: 1.25;
}

.story-title a { color: var(--text-strong); }
.story-title a:hover { color: var(--accent-hover); }

.story-byline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 10px;
    font-size: 15px;
    color: var(--text-muted);
}

.story-byline a { color: var(--text); }
.story-byline a:hover { color: var(--accent-hover); }

.byline-author { font-weight: 600; color: var(--text); }

.byline-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-variant-numeric: tabular-nums;
}

.byline-item svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.story-excerpt {
    margin: 0;
    font-size: 17px;
    line-height: 1.7;
    color: var(--text);
}

/* --- Rating --- */

.rating {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}

.stars {
    position: relative;
    display: inline-block;
    font-size: 16px;
    line-height: 1;
    letter-spacing: 1px;
    color: var(--border-strong);
    white-space: nowrap;
}

.stars-fill {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    color: var(--star);
    white-space: nowrap;
}

.rating-value { color: var(--text); font-weight: 600; }
.rating-count { color: var(--text-muted); font-size: 13px; }

/* --- Series position, e.g. 2 / 5 --- */

.series-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* --- Country --- */

.country-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 15px;
    color: var(--text-muted);
}

.country-tag:hover { color: var(--accent-hover); }

/* =============================================================
 *  Pagination
 * ============================================================= */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 48px;
}

.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: var(--bg-soft);
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.pagination .page-numbers:hover {
    background: var(--bg-softer);
    color: var(--text-strong);
}

.pagination .page-numbers.current {
    background: var(--accent);
    color: #fff;
}

.pagination .page-numbers.dots {
    background: transparent;
    color: var(--text-muted);
}

/* =============================================================
 *  Long-form copy block (the SEO text at the foot of a listing)
 * ============================================================= */

.prose-block {
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.prose-block h2 { font-size: 27px; }
.prose-block h3 { font-size: 21px; margin-top: 28px; }

.prose-block p {
    max-width: 76ch;
    font-size: 17px;
    color: var(--text);
}

/* =============================================================
 *  Footer
 * ============================================================= */

.site-footer {
    margin-top: 80px;
    padding: 40px 0 32px;
    background: linear-gradient(to bottom, var(--footer-fade), transparent);
    border-top: 1px solid var(--border);
}

.footer-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 32px;
    margin-bottom: 32px;
}

.footer-col h4 {
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-strong);
}

.footer-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-col li { margin-bottom: 7px; }

.footer-col a {
    font-size: 16px;
    color: var(--text);
}

.footer-col a:hover { color: var(--accent-hover); }

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-size: 15px;
    color: var(--text-muted);
}

.footer-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.age-mark {
    padding: 2px 7px;
    border: 1px solid var(--border-strong);
    font-weight: 700;
    font-size: 13px;
}

/* =============================================================
 *  Responsive
 * ============================================================= */

@media (max-width: 820px) {

    .hero { padding: 36px 0 28px; }
    .hero h1 { font-size: 40px; }
    .hero-lead { font-size: 18px; }

    .section-heading { font-size: 27px; margin: 40px 0 18px; }

    .story-title { font-size: 22px; }

    .menu-toggle { display: inline-flex; }

    .header-nav {
        position: fixed;
        inset: 64px 0 auto 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin: 0;
        padding: 8px 0;
        background: var(--bg-soft);
        border-bottom: 1px solid var(--border-strong);
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }

    .header-nav[hidden] { display: none; }

    .header-nav a { padding: 12px 20px; font-size: 17px; }
}

@media (max-width: 480px) {
    .hero h1 { font-size: 34px; }

    .hero-search { flex-direction: column; }

    .hero-search input {
        border-right: 1px solid var(--border-strong);
        border-bottom: 0;
    }

    .category-chip { font-size: 15px; padding: 7px 12px; }

    .story-card { margin-bottom: 32px; padding-left: 12px; }

    .pagination .page-numbers { min-width: 36px; height: 36px; padding: 0 9px; }
}

/* =============================================================
 *  Single story
 *
 *  The reading column is narrower than the site container. Line length is
 *  the one typographic decision that decides whether long fiction gets read,
 *  and 1120px of prose does not.
 * ============================================================= */

.reading-column {
    max-width: 760px;
}

.story-single {
    padding-top: 40px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-size: 15px;
    color: var(--text-muted);
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-hover); }

.single-title {
    margin: 12px 0 14px;
    font-size: 45px;
    line-height: 1.12;
}

.single-byline {
    padding-bottom: 24px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

/* --- The prose itself --- */

.story-body {
    font-size: 20px;
    line-height: 1.85;
    color: var(--prose);
}

.story-body p { margin: 0 0 26px; }

.story-body p:first-of-type::first-letter {
    float: left;
    margin: 6px 10px 0 0;
    font-size: 63px;
    font-weight: 800;
    line-height: .82;
    color: var(--accent-hover);
}

.story-body h2,
.story-body h3 {
    margin: 40px 0 16px;
    font-size: 27px;
}

.story-body blockquote {
    margin: 32px 0;
    padding: 4px 0 4px 20px;
    border-left: 4px solid var(--accent-line);
    color: var(--text);
    font-style: italic;
}

.story-body em { color: var(--prose-em); }
.story-body strong { color: var(--text-strong); }

.story-body hr {
    margin: 40px auto;
    width: 80px;
    border: 0;
    border-top: 1px solid var(--border-strong);
}

/* --- Premium wall --- */

.story-body.is-locked {
    position: relative;
    max-height: 320px;
    overflow: hidden;
}

.story-body.is-locked::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 160px;
    background: linear-gradient(to bottom, var(--fade-from), var(--bg));
}

.premium-wall {
    margin: 0 0 40px;
    padding: 28px 24px;
    background: var(--bg-soft);
    border-top: 3px solid var(--premium);
    text-align: center;
}

.premium-wall h3 { font-size: 24px; margin-bottom: 10px; }
.premium-wall p { font-size: 17px; }

.premium-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 20px 0 0;
}

/* --- Tags --- */

.story-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 40px 0 0;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.tag-plain {
    padding: 4px 10px;
    background: var(--bg-soft);
    color: var(--text);
    font-size: 15px;
}

.tag-plain:hover {
    background: var(--accent-soft);
    color: var(--accent-text);
}

/* --- Rate it --- */

.rate-box {
    margin: 40px 0 0;
    padding: 24px;
    background: var(--bg-soft);
    text-align: center;
}

.rate-title {
    margin-bottom: 14px;
    font-size: 20px;
}

.rate-stars {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 12px;
}

.rate-star {
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--border-strong);
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    transition: color .12s, transform .12s;
}

.rate-star:hover:not(:disabled),
.rate-star.is-lit {
    color: var(--star);
}

.rate-star:hover:not(:disabled) { transform: translateY(-2px); }

.rate-star:disabled { cursor: default; }

.rate-box[data-voted="1"] .rate-star.is-lit { color: var(--star); }

.rate-status {
    margin: 0;
    font-size: 16px;
    color: var(--text-muted);
}

/* --- Series navigation --- */

.series-nav {
    margin-top: 40px;
    padding: 20px;
    background: var(--bg-soft);
    border-left: 4px solid var(--accent-line);
}

.series-nav-label {
    display: block;
    margin-bottom: 14px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
}

.series-nav-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.series-nav-item {
    display: block;
    padding: 12px 14px;
    background: var(--bg);
    color: var(--text);
}

.series-nav-item:hover { background: var(--bg-softer); }
.series-nav-item.is-next { text-align: right; }

.series-nav-dir {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--accent-hover);
}

.series-nav-title {
    display: block;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-strong);
}

/* --- Author --- */

.author-box {
    margin-top: 40px;
    padding: 22px 24px;
    background: var(--bg-soft);
}

.author-box-name { margin-bottom: 8px; font-size: 21px; }
.author-box-name a { color: var(--text-strong); }
.author-box-name a:hover { color: var(--accent-hover); }

.author-box-bio {
    margin-bottom: 10px;
    font-size: 17px;
    color: var(--text);
}

.author-box-count {
    margin: 0;
    font-size: 15px;
    color: var(--text-muted);
}

/* --- Related --- */

.related-block { margin-top: 72px; }

/* =============================================================
 *  Comments
 * ============================================================= */

.comments-area {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.comments-title { font-size: 25px; margin-bottom: 24px; }

.comment-list {
    list-style: none;
    margin: 0 0 32px;
    padding: 0;
}

.comment-list ul.children {
    list-style: none;
    margin: 16px 0 0 20px;
    padding-left: 16px;
    border-left: 2px solid var(--border);
}

.comment-row { margin-bottom: 20px; }

.comment-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 4px;
}

.comment-author {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-strong);
}

.comment-date { font-size: 13px; color: var(--text-muted); }

.comment-content {
    font-size: 17px;
    line-height: 1.7;
}

.comment-content p { margin: 0 0 10px; }

.comment-reply-link {
    font-size: 15px;
    color: var(--text-muted);
}

.comment-reply-link:hover { color: var(--accent-hover); }

.comment-respond {
    padding: 24px;
    background: var(--bg-soft);
}

.comment-reply-title { font-size: 20px; margin-bottom: 14px; }

.comment-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-strong);
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    color: var(--text-strong);
    font-family: inherit;
    font-size: 17px;
}

.comment-form textarea { min-height: 120px; resize: vertical; }

.comment-form input:focus,
.comment-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.comment-form .submit {
    padding: 11px 22px;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.comment-form .submit:hover { background: var(--accent-hover); }

.comment-notes,
.logged-in-as { font-size: 15px; color: var(--text-muted); }

@media (max-width: 820px) {
    .single-title { font-size: 34px; }
    .story-body { font-size: 19px; line-height: 1.8; }
    .story-body p:first-of-type::first-letter { font-size: 52px; }
    .series-nav-item.is-next { text-align: left; }
    .related-block { margin-top: 48px; }
}

/* =============================================================
 *  Archives, author pages and index screens
 * ============================================================= */

.archive-header {
    padding: 40px 0 32px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.archive-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0 10px;
    font-size: 40px;
}

.archive-emoji { font-size: 34px; line-height: 1; }

.archive-meta {
    margin: 0;
    font-size: 16px;
    color: var(--text-muted);
}

.archive-description {
    max-width: 70ch;
    margin-top: 14px;
    font-size: 17px;
    color: var(--text);
}

/* --- Author --- */

.author-page-bio {
    max-width: 70ch;
    margin: 12px 0 20px;
    font-size: 18px;
    color: var(--text);
}

.author-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    margin: 0 0 20px;
}

.author-stat dt {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
}

.author-stat dd {
    margin: 2px 0 0;
    font-size: 27px;
    font-weight: 800;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}

.author-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* --- Term index --- */

.term-list {
    list-style: none;
    margin: 24px 0 0;
    padding: 0;
}

.term-row {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.term-link {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.term-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-strong);
}

.term-link:hover .term-name { color: var(--accent-hover); }

.term-count {
    flex-shrink: 0;
    font-size: 15px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.term-description {
    margin: 6px 0 0;
    font-size: 16px;
    color: var(--text-muted);
}

/* --- Top rated --- */

.ranked-row {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.rank-number {
    flex-shrink: 0;
    width: 44px;
    padding-top: 2px;
    font-size: 29px;
    font-weight: 800;
    line-height: 1;
    color: var(--border-strong);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.ranked-row:nth-child(-n+3) .rank-number { color: var(--accent-hover); }

.ranked-story { flex: 1; min-width: 0; }

/* --- Empty states --- */

.empty-state {
    padding: 56px 0;
    text-align: center;
}

.empty-state p {
    font-size: 18px;
    color: var(--text);
}

.empty-hint {
    margin-top: 28px;
    font-size: 16px;
    color: var(--text-muted);
}

.category-grid-centred { justify-content: center; }

.search-again { margin-top: 20px; max-width: 480px; margin-left: 0; }

@media (max-width: 820px) {
    .archive-header { padding: 28px 0 22px; }
    .archive-title { font-size: 30px; }
    .author-stats { gap: 22px; }
    .author-stat dd { font-size: 22px; }
    .rank-number { width: 30px; font-size: 21px; }
    .ranked-row { gap: 12px; }
}

/* =============================================================
 *  Static pages and 404
 * ============================================================= */

.page-updated {
    margin: 0 0 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    color: var(--text-muted);
}

/* A page is not a story: no drop cap on ordinary prose */
.page-body p:first-of-type::first-letter {
    float: none;
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    color: inherit;
}

.page-body ul,
.page-body ol { margin: 0 0 24px; padding-left: 22px; }
.page-body li { margin-bottom: 8px; }

.error-page {
    padding: 64px 0 48px;
    text-align: center;
}

.error-code {
    margin: 0 0 8px;
    font-size: 103px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--bg-soft);
}

.error-title { font-size: 38px; margin-bottom: 12px; }

.error-lead {
    max-width: 520px;
    margin: 0 auto 28px;
    font-size: 18px;
    color: var(--text);
}

/* =============================================================
 *  18+ entry screen
 * ============================================================= */

html.age-locked,
html.age-locked body { overflow: hidden; }

.age-gate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--overlay-bg);
}

.age-gate-panel {
    width: 100%;
    max-width: 440px;
    padding: 32px 28px 24px;
    background: var(--bg-soft);
    border-top: 3px solid var(--accent);
    text-align: center;
}

.age-gate-mark {
    display: inline-block;
    margin-bottom: 18px;
    padding: 6px 12px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .04em;
}

.age-gate-title {
    margin: 0 0 14px;
    font-size: 25px;
}

.age-gate-text {
    margin: 0 0 24px;
    font-size: 17px;
    line-height: 1.7;
    color: var(--text);
}

.age-gate-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 20px;
}

.age-gate-links {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin: 0 0 12px;
    font-size: 15px;
}

.age-gate-links a { color: var(--text-muted); }
.age-gate-links a:hover { color: var(--accent-hover); }

.age-gate-note {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
}

@media (max-width: 480px) {
    .error-code { font-size: 72px; }
    .error-title { font-size: 29px; }
    .age-gate-panel { padding: 26px 18px 20px; }
    .age-gate-title { font-size: 21px; }
}

/* =============================================================
 *  Account and auth screens
 * ============================================================= */

.auth-container {
    max-width: 460px;
    padding-top: 44px;
    padding-bottom: 60px;
}

.auth-card {
    padding: 30px 28px 26px;
    background: var(--bg-soft);
    border-top: 3px solid var(--accent);
}

.auth-title {
    margin: 0 0 20px;
    font-size: 27px;
}

.auth-note {
    margin: 0 0 20px;
    font-size: 17px;
    line-height: 1.65;
    color: var(--text);
}

.auth-links {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 20px;
    font-size: 15px;
}

.auth-links a { color: var(--text-muted); }
.auth-links a:hover { color: var(--accent-hover); }

/* --- Form controls --- */

.field-label {
    display: block;
    margin: 16px 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-strong);
}

.account-form > .field-label:first-of-type { margin-top: 0; }

.field-input {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    color: var(--text-strong);
    font-family: inherit;
    font-size: 17px;
}

textarea.field-input { resize: vertical; line-height: 1.6; }

.field-input::placeholder { color: var(--text-muted); }

.field-input:focus {
    outline: none;
    border-color: var(--accent);
}

.field-hint {
    margin: 6px 0 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-muted);
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 14px 0 0;
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    cursor: pointer;
}

.checkbox-row input { margin-top: 3px; }
.checkbox-row a { color: var(--accent-hover); }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

/* The honeypot must be reachable by nothing but a bot */
.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* --- Messages --- */

.form-error,
.form-notice {
    margin-bottom: 16px;
    padding: 11px 14px;
    font-size: 16px;
    line-height: 1.55;
}

.form-error {
    background: var(--danger-bg);
    border-left: 3px solid var(--danger);
    color: var(--danger-text);
}

.form-notice {
    background: var(--notice-bg);
    border-left: 3px solid var(--accent);
    color: var(--accent-text);
}

/* --- Account page --- */

.account-block {
    margin-bottom: 36px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.account-block:last-of-type { border-bottom: 0; }

.form-section-title {
    margin-bottom: 14px;
    font-size: 21px;
}

.premium-note {
    padding: 18px 20px 20px;
    background: var(--bg-soft);
    border-bottom: 0;
    border-left: 3px solid var(--premium);
}

.premium-note p { margin: 0; font-size: 17px; }

.danger-zone {
    padding: 22px 20px;
    border: 1px solid var(--danger-border);
    border-bottom: 1px solid var(--danger-border);
}

.danger-zone .form-section-title { color: var(--danger-text); }

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger-text);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.site-notice {
    margin: 20px 0;
    padding: 12px 16px;
    background: var(--bg-soft);
    border-left: 3px solid var(--accent);
    font-size: 16px;
    color: var(--text);
}

@media (max-width: 560px) {
    .auth-container { padding-top: 26px; }
    .auth-card { padding: 22px 18px 20px; }
    .auth-links { flex-direction: column; gap: 8px; }
}

/* =============================================================
 *  Writing a story
 * ============================================================= */

.write-form select.field-input {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%),
                      linear-gradient(135deg, var(--text) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 38px;
}

.story-textarea {
    min-height: 420px;
    font-size: 18px;
    line-height: 1.8;
    resize: vertical;
}

.word-count {
    float: right;
    font-variant-numeric: tabular-nums;
}

.word-count.is-short { color: var(--premium); }

.series-fields {
    margin: 22px 0 0;
    padding: 18px;
    border: 1px solid var(--border-strong);
}

.series-fields legend { padding: 0 8px; margin: 0; }

.series-numbers {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.series-numbers label {
    font-size: 16px;
    color: var(--text-muted);
}

.series-numbers .field-input { width: 90px; }

/* =============================================================
 *  My stories
 * ============================================================= */

.my-story-list {
    list-style: none;
    margin: 28px 0 0;
    padding: 0;
}

.my-story {
    margin-bottom: 24px;
    padding: 18px 20px;
    background: var(--bg-soft);
    border-left: 4px solid var(--border-strong);
}

.my-story.status-publish { border-left-color: var(--accent-line); }
.my-story.status-pending { border-left-color: var(--premium); }

.my-story-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.status-pill {
    padding: 2px 9px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: var(--bg-softer);
    color: var(--text);
}

.status-pill.status-publish { background: var(--accent-soft); color: var(--accent-text); }
.status-pill.status-pending { background: var(--premium-soft); color: var(--premium); }

.my-story-date {
    font-size: 13px;
    color: var(--text-muted);
}

.my-story-title {
    margin: 0 0 6px;
    font-size: 22px;
}

.my-story-title a { color: var(--text-strong); }
.my-story-title a:hover { color: var(--accent-hover); }

.my-story-stats {
    margin: 0 0 10px;
    font-size: 15px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.my-story-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.inline-form { display: inline; margin: 0; }

.btn-small {
    padding: 6px 13px;
    font-size: 15px;
}

.my-story-note {
    font-size: 13px;
    color: var(--text-muted);
}

@media (max-width: 560px) {
    .story-textarea { min-height: 320px; }
    .my-story { padding: 14px 16px; }
    .my-story-title { font-size: 20px; }
}


/* -------------------------------------------------------------
 *  The report form, and the editor's note to an author
 * ----------------------------------------------------------- */

.report-title a { color: inherit; }

/* The submission itself, scrollable so one long story does not bury the rest
   of the queue. An editor still reads it here rather than on another page. */
.editor-note {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-left: 3px solid var(--accent-line);
    background: var(--bg-soft);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
}

.editor-note strong {
    display: block;
    color: var(--text-strong);
    margin-bottom: 4px;
    font-size: 15px;
}

/* The report form under a story: closed by default, because most readers are
   here to read and the form should not compete with the last paragraph. */
.report-box {
    margin: 40px 0 0;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.report-box summary {
    cursor: pointer;
    font-size: 15px;
    color: var(--text-muted);
    letter-spacing: .04em;
}

.report-box summary:hover { color: var(--text); }

.report-form { margin-top: 18px; }

.radio-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 16px;
    line-height: 1.5;
    cursor: pointer;
}

.radio-row input { margin-top: 3px; }

/* -------------------------------------------------------------
 *  Light
 *
 *  Only the colours change. Every rule below this point is written
 *  against the tokens, so the two modes share one stylesheet and
 *  cannot drift apart.
 *
 *  The system setting decides, unless the reader has picked a mode
 *  with the toggle in the header — that choice sets data-theme on
 *  <html> and wins in both directions.
 * ----------------------------------------------------------- */

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
    /* Surfaces - paper, not white-on-white */
    --bg:            #ffffff;
    --bg-soft:       #f4f5f8;
    --bg-softer:     #e8ebf0;
    --border:        #e4e7ec;
    --border-strong: #cbd2dc;

    /* Text */
    --text:          #4b5563;
    --text-strong:   #0f172a;
    --text-muted:    #6b7280;

    /* Accent - the same indigo, darkened until it holds on white */
    --accent:        #4f46e5;
    --accent-hover:  #4338ca;
    --accent-soft:   #e0e7ff;
    --accent-text:   #4338ca;
    --accent-line:   #6366f1;

    --premium:       #b45309;
    --star:          #d97706;

    --header-bg:     rgba(255, 255, 255, .92);
    --overlay-bg:    rgba(241, 245, 249, .97);
    --footer-fade:   #f4f5f8;
    --fade-from:     rgba(255, 255, 255, 0);
    --prose:         #334155;
    --prose-em:      #1e293b;
    --chip-hover:    #4338ca;
    --premium-soft:  #fdf0d5;

    --danger:        #dc2626;
    --danger-text:   #b91c1c;
    --danger-bg:     rgba(220, 38, 38, .08);
    --danger-border: rgba(220, 38, 38, .30);
    --notice-bg:     rgba(79, 70, 229, .08);

    color-scheme: light;
    }
}

:root[data-theme="light"] {
    /* Surfaces - paper, not white-on-white */
    --bg:            #ffffff;
    --bg-soft:       #f4f5f8;
    --bg-softer:     #e8ebf0;
    --border:        #e4e7ec;
    --border-strong: #cbd2dc;

    /* Text */
    --text:          #4b5563;
    --text-strong:   #0f172a;
    --text-muted:    #6b7280;

    /* Accent - the same indigo, darkened until it holds on white */
    --accent:        #4f46e5;
    --accent-hover:  #4338ca;
    --accent-soft:   #e0e7ff;
    --accent-text:   #4338ca;
    --accent-line:   #6366f1;

    --premium:       #b45309;
    --star:          #d97706;

    --header-bg:     rgba(255, 255, 255, .92);
    --overlay-bg:    rgba(241, 245, 249, .97);
    --footer-fade:   #f4f5f8;
    --fade-from:     rgba(255, 255, 255, 0);
    --prose:         #334155;
    --prose-em:      #1e293b;
    --chip-hover:    #4338ca;
    --premium-soft:  #fdf0d5;

    --danger:        #dc2626;
    --danger-text:   #b91c1c;
    --danger-bg:     rgba(220, 38, 38, .08);
    --danger-border: rgba(220, 38, 38, .30);
    --notice-bg:     rgba(79, 70, 229, .08);

    color-scheme: light;
}

/* The toggle itself: one button, showing the mode it will switch to. */
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun  { display: block; }

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-toggle .icon-sun  { display: none; }
    :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
}

:root[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }


/* -------------------------------------------------------------
 *  Headline tracking
 *
 *  Inter spaces its letters for running text. At display sizes and
 *  heavy weights that spacing reads loose, so the titles pull in.
 * ----------------------------------------------------------- */

h1, h2, h3,
.story-title,
.archive-title,
.my-story-title,
.site-title {
    letter-spacing: -.02em;
}

.hero-title,
.archive-title {
    letter-spacing: -.03em;
}


/* -------------------------------------------------------------
 *  Search in the header
 *
 *  A field beside the icon, not a takeover: the reader can still see
 *  where they are and reach the menu while the box is open. The icon
 *  itself never moves - it becomes the box's right-hand edge, and
 *  turns into a cross under the cursor so it can close what it opened.
 * ----------------------------------------------------------- */

.header-search {
    display: flex;
    align-items: center;
    margin: 0;
}

/* A class rule beats the browser's own [hidden], so say it here too -
   without this the field sits open on every page load. The form itself
   always stays: it is what holds the button. */
.header-search-input[hidden] { display: none; }

.header-search-input {
    width: 220px;
    height: var(--control-h);
    padding: 0 14px;
    font-family: inherit;
    font-size: 16px;
    color: var(--text-strong);
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-right: 0;
}

/* No focus ring on either half. The browser draws its own outside the
   border, which makes the field look taller than the button beside it -
   the border colour carries the focus instead. */
.header-search-input:focus,
.header-search-input:focus-visible,
.search-toggle:focus,
.search-toggle:focus-visible {
    outline: none;
    box-shadow: none;
}

.header-search-input::placeholder { color: var(--text-muted); }

/* Open, the button is the right end of the box rather than a
   separate control floating beside it. */
.search-open .search-toggle {
    border: 1px solid var(--border-strong);
    border-left: 0;
}

.search-open .header-search-input:focus,
.search-open .header-search-input:focus + .search-toggle { border-color: var(--accent); }

.search-open .search-toggle:hover { background: transparent; }

/* One button, two states. Closed it is a magnifier; open, it turns
   into a cross as soon as the cursor reaches it. */
.search-toggle .icon-close { display: none; }

.search-open .search-toggle:hover .icon-glass,
.search-open .search-toggle:focus-visible .icon-glass { display: none; }

.search-open .search-toggle:hover .icon-close,
.search-open .search-toggle:focus-visible .icon-close { display: block; }

.search-open .search-toggle:hover { color: var(--accent); }

@media (max-width: 600px) {
    .header-search-input { width: 150px; }
}


/* -------------------------------------------------------------
 *  Favourites, the language menu, and the comment honeypot
 * ----------------------------------------------------------- */

.fav-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
    transition: color .15s;
}

.fav-btn svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: fill .15s, stroke .15s;
}

.fav-btn:hover { color: var(--danger-text); }

/* Held, the heart fills. Colour alone would not survive a reader who
   cannot see it, so aria-pressed carries the same fact. */
.fav-btn.is-held { color: var(--danger); }
.fav-btn.is-held svg { fill: currentColor; }

.fav-btn:disabled { opacity: .5; cursor: default; }

.fav-compact { font-size: 13px; }
.fav-compact svg { width: 16px; height: 16px; }

/* On the story itself the heart stands on its own line, above the tags. */
.story-body + .fav-btn,
.fav-btn:not(.fav-compact) {
    margin-top: 4px;
}

/* --- Language --------------------------------------------------------- */

.lang-switch { position: relative; }

.lang-code {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .04em;
}

.lang-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 950;
    min-width: 170px;
    padding: 6px 0;
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
}

.lang-menu[hidden] { display: none; }

.lang-option {
    display: block;
    padding: 9px 16px;
    font-size: 15px;
    color: var(--text);
}

.lang-option:hover {
    background: var(--bg-softer);
    color: var(--text-strong);
}

.lang-option.is-current {
    color: var(--accent-text);
    font-weight: 600;
}

/* --- The honeypot -----------------------------------------------------
 *
 * Moved off-screen rather than display:none. A bot that reads the stylesheet
 * skips a hidden field; one that is merely off-screen still looks like an
 * ordinary website box worth filling in, which is the whole point.
 * --------------------------------------------------------------------- */

.comment-website-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}


/* The other door on the sign-in screen: a reader with no account needs an
   obvious way forward, not a link tucked beside "forgot your password". */
.auth-alt {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.auth-alt-note {
    margin: 0 0 14px;
    font-size: 15px;
    color: var(--text-muted);
}

.auth-alt-note:last-child {
    margin: 14px 0 0;
    font-size: 14px;
}
