/* ════════════════════════════════════════
   FONTS
   ════════════════════════════════════════ */

@font-face {
    font-family: "Cooper Black";
    src:
        url("../fonts/CooperBlack.woff2") format("woff2"),
        url("../fonts/COOPBL.woff") format("woff");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ════════════════════════════════════════
   RESET
   ════════════════════════════════════════ */

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

/* ════════════════════════════════════════
   VARIABLES
   ════════════════════════════════════════ */

:root {
    --bg: #fffff8;
    --text: #111111;
    --accent: #ff9500;
    --pink: #ff2d9b;
    --purple: #7b00ff;
    --muted: #7a6a58;
    --border: #111111;
    --trans: 0.3s ease;
    --font-display: "Cooper Black", "Cooper Std Black", "Arial Black", serif;
    --font-heading: "Fraunces", Georgia, serif;
    --font-body: "EB Garamond", Georgia, serif;
}

.night {
    --bg: #0f0f0f;
    --text: #fffff8;
    --accent: #ff9500;
    --pink: #ff2d9b;
    --purple: #a855f7;
    --muted: #9b8b7b;
    --border: #fffff8;
}

/* ════════════════════════════════════════
   BASE
   ════════════════════════════════════════ */

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    background-image: radial-gradient(
        circle,
        rgba(17, 17, 17, 0.11) 1px,
        transparent 1px
    );
    background-size: 20px 20px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: clamp(18px, 1rem + 0.3vw, 21px);
    line-height: 1.8;
    transition:
        background-color var(--trans),
        color var(--trans);
    min-height: 100vh;
}

body.night {
    background-image: radial-gradient(
        circle,
        rgba(255, 255, 248, 0.07) 1px,
        transparent 1px
    );
}

/* Paper texture overlay */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.5;
}

/* ════════════════════════════════════════
   LAYOUT — site structure & content width
   ════════════════════════════════════════ */

.site-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-main {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* .wrap is the inner content container — controls the actual
   max line/content width independent of .site-main's padding box */
.wrap {
    max-width: 80rem;
    margin: 0 auto;
}

/* ════════════════════════════════════════
   HEADER
   ════════════════════════════════════════ */

.site-header {
    position: relative;
    overflow: hidden;
    min-height: 280px;
    display: flex;
    align-items: stretch;
    margin-bottom: 3.5rem;
}

#psychCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.header-inner {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 2.5rem 2rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
}

.logo-link {
    text-decoration: none;
}

.site-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 3rem);
    line-height: 1;
    letter-spacing: -0.02em;
    color: #ffe600;
    -webkit-text-stroke: 15px #111111;
    paint-order: stroke fill;
    text-shadow:
        -3px -3px 0 #111111,
        3px -3px 0 #111111,
        -3px 3px 0 #111111,
        3px 3px 0 #111111,
        -3px 0 0 #111111,
        3px 0 0 #111111,
        0 -3px 0 #111111,
        0 3px 0 #111111;
}

.site-tagline {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 700;
    font-size: 1.3rem;
    color: #fffff8;
    margin-top: 0.4rem;
    -webkit-text-stroke: 10px #111111;
    paint-order: stroke fill;
    text-shadow: none;
    letter-spacing: 0.02em;
}

.hd-right {
    display: flex;
    align-items: center;
    gap: 2rem;
    position: absolute;
    top: 2rem;
    right: 2rem;
}

/* ── Navigation ── */
.site-nav .nav,
.site-nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    font-family: var(--font-heading);
    font-size: 0.95rem;
}

.site-nav .nav a,
.site-nav ul a {
    color: #fffff8;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 248, 0.45);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
    transition:
        border-bottom-color 0.2s,
        opacity 0.2s;
}

.site-nav .nav a:hover,
.site-nav ul a:hover {
    border-bottom-color: #fffff8;
    opacity: 0.85;
}

/* ── Day/night toggle ── */
.tog {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 248, 0.65);
    color: #fffff8;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tog:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: #fffff8;
    transform: scale(1.08);
}

.tog:focus-visible {
    outline: 2px solid #fffff8;
    outline-offset: 3px;
}

/* ════════════════════════════════════════
   SHARED COMPONENTS — pills, meta, dividers
   ════════════════════════════════════════ */

/* ── Category pills ── */
.cat {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pink);
    background: rgba(255, 45, 155, 0.1);
    border: 1px solid rgba(255, 45, 155, 0.3);
    padding: 0.2rem 0.75rem;
    border-radius: 20px;
    margin-bottom: 0.9rem;
    transition:
        background 0.2s,
        color 0.2s,
        border-color 0.2s;
    text-decoration: none;
}

.cat:hover {
    background: var(--pink);
    color: #fffff8;
    border-color: var(--pink);
}

/* ── Post meta (date / reading time / author) ── */
.meta {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.meta .date {
    color: var(--purple);
}
.meta .time {
    color: var(--muted);
}
.meta .author {
    color: var(--pink);
}

/* ── Section divider ── */
.div {
    text-align: center;
    color: var(--purple);
    font-size: 1.4rem;
    letter-spacing: 0.6em;
    margin: 3rem 0;
}

/* ── Drop cap (used on homepage excerpt + first post paragraph) ── */
.dc::first-letter,
.gh-content > p:first-child::first-letter,
.post-content > p:first-child::first-letter {
    font-family: var(--font-display);
    font-size: 4.2em;
    float: left;
    line-height: 0.78;
    margin-right: 0.08em;
    margin-top: 0.08em;
    color: var(--accent);
}

/* ════════════════════════════════════════
   HOMEPAGE — featured post & grid cards
   ════════════════════════════════════════ */

.featured {
    margin-bottom: 4rem;
}

.featured-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.7rem, 3.5vw, 2.9rem);
    line-height: 1.15;
    letter-spacing: -0.025em;
    margin-bottom: 1.1rem;
}

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

.exc {
    font-size: 1.05rem;
    max-width: 68ch;
    margin-bottom: 1.1rem;
    line-height: 1.85;
}

/* ── Read more link ── */
.rdmore {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1.1rem;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 149, 0, 0.4);
    padding-bottom: 1px;
    transition:
        color 0.2s,
        border-color 0.2s;
}

.rdmore .arr {
    display: inline-block;
    transition: transform 0.2s;
}
.rdmore:hover {
    color: var(--pink);
    border-color: rgba(255, 45, 155, 0.4);
}
.rdmore:hover .arr {
    transform: translateX(5px);
}

/* ── Post grid ── */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
    margin-bottom: 4rem;
}

@media (max-width: 700px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

.card {
    border-top: 2px solid var(--border);
    padding: 1.25rem 0 0.5rem;
    transition:
        border-top-color 0.2s,
        transform 0.2s;
}

.card:hover {
    transform: translateY(-3px);
    border-top-color: var(--pink);
}

.card h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.3;
    margin-bottom: 0.65rem;
}

.card h3 a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s;
}
.card:hover h3 a {
    color: var(--pink);
}
.card p {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.65;
    margin-bottom: 0.65rem;
}

/* ════════════════════════════════════════
   POST PAGE — header, two-column tufte layout
   ════════════════════════════════════════ */

.ph {
    max-width: 72ch;
    margin-bottom: 3rem;
}

.post-title {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: clamp(1.9rem, 4vw, 3.1rem);
    line-height: 1.1;
    letter-spacing: -0.025em;
    margin: 0.6rem 0 1.1rem;
}

/* ── Tufte-style two-column layout: main text (60%) + margin (40%) ── */
.pb-wrap {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 3rem;
    align-items: start;
    margin-bottom: 4rem;
}

@media (max-width: 860px) {
    .pb-wrap {
        grid-template-columns: 1fr;
    }
}

/* ── Main content typography ── */
.gh-content,
.post-content {
    position: relative; /* anchors absolutely-positioned sidenotes */
    font-size: 1.05rem;
    line-height: 1.85;
}

.gh-content p,
.post-content p {
    margin-bottom: 1.6rem;
}

.gh-content h2,
.post-content h2 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 2.5rem 0 1rem;
}

.gh-content h3,
.post-content h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    letter-spacing: -0.01em;
    margin: 2rem 0 0.75rem;
}

/* ── Body links ── */
.gh-content a,
.post-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(255, 149, 0, 0.4);
    text-underline-offset: 3px;
    transition:
        color 0.2s,
        text-decoration-color 0.2s;
}

.gh-content a:hover,
.post-content a:hover {
    color: var(--pink);
    text-decoration-color: rgba(255, 45, 155, 0.6);
}

/* ── Blockquotes as pull quotes ── */
.gh-content blockquote,
.post-content blockquote {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2.2vw, 1.65rem);
    line-height: 1.35;
    color: var(--accent);
    border-left: 4px solid var(--accent);
    background: rgba(255, 149, 0, 0.05);
    padding: 1rem 1.25rem 1rem 1.5rem;
    margin: 2.75rem 0;
    font-style: normal;
    border-radius: 0 8px 8px 0;
    transition:
        color 0.2s,
        border-color 0.2s,
        background 0.2s;
}

.gh-content blockquote:hover,
.post-content blockquote:hover {
    color: var(--pink);
    border-color: var(--pink);
    background: rgba(255, 45, 155, 0.05);
}

/* ── Code ── */
.gh-content code,
.post-content code {
    font-family: "Courier New", monospace;
    font-size: 0.85em;
    background: rgba(123, 0, 255, 0.08);
    color: var(--purple);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

.gh-content pre,
.post-content pre {
    background: rgba(17, 17, 17, 0.05);
    border: 1px solid var(--border);
    padding: 1.5rem;
    overflow-x: auto;
    margin: 2rem 0;
    border-radius: 4px;
}

.night .gh-content pre,
.night .post-content pre {
    background: rgba(255, 255, 248, 0.05);
}

/* ── Inline images ── */
.gh-content img,
.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem 0;
}

/* ════════════════════════════════════════
   MARGIN COLUMN — sidenotes & margin notes
   ════════════════════════════════════════ */

/* ── Sidenotes: citation references, diamond symbol,
   absolutely positioned + JS-aligned to their reference ── */
.sidenote-ref {
    font-family: var(--font-heading);
    font-size: 0.7em;
    color: var(--accent);
    cursor: default;
    font-style: normal;
    margin: 0 0.1em;
}

.sidenote {
    position: absolute;
    left: calc(100% + 3rem);
    width: 65%;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--muted);
    font-style: italic;
    border-left: 2px solid var(--accent);
    padding-left: 1.25rem;
}

.sidenote-number {
    color: var(--accent);
    font-style: normal;
    font-size: 0.9em;
    margin-right: 0.4rem;
}

@media (max-width: 860px) {
    .sidenote {
        position: static;
        width: 100%;
        margin: 1rem 0 1.5rem;
    }
}

/* ── Margin notes: tangents, asides, images — float-based,
   flexible positioning (no JS alignment needed) ── */
.gh-content .margin-note {
    float: right;
    clear: right;
    width: 65%;
    margin-right: -72%;
    font-family: var(--font-heading);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--muted);
    font-style: italic;
    border-left: 2px solid var(--pink);
    padding-left: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 860px) {
    .gh-content .margin-note {
        float: none;
        width: 100%;
        margin: 1rem 0 1.5rem;
    }
}

.margin-image {
    width: 100%;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    display: block;
}

@media (max-width: 860px) {
    .margin-image {
        max-width: 320px;
        margin: 0 auto 0.5rem;
    }
}

/* ════════════════════════════════════════
   GHOST CARD WIDTHS & FEATURE IMAGE
   ════════════════════════════════════════ */

.kg-width-wide {
    margin-left: -4rem;
    margin-right: -4rem;
}

.kg-width-full {
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    width: 100vw;
}

.kg-image {
    max-width: 100%;
    height: auto;
    display: block;
}

.feature-image-wrap {
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    max-height: 55vh;
    overflow: hidden;
    margin-bottom: 3rem;
}

.feature-image-wrap::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(transparent, var(--bg));
}

.feature-image {
    width: 100%;
    height: 55vh;
    object-fit: cover;
    display: block;
}

/* ════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════ */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    margin: 3rem 0;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 149, 0, 0.4);
    transition: color 0.2s;
}

.pagination a:hover {
    color: var(--pink);
}

/* ════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════ */

.site-footer {
    border-top: 2px solid var(--border);
    padding: 1.75rem 2rem;
    margin-top: 4rem;
    max-width: 1140px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 0.82rem;
    color: var(--muted);
    flex-wrap: wrap;
    gap: 1rem;
    transition: border-color var(--trans);
}

.soff {
    font-style: italic;
    color: var(--purple);
    transition: color 0.2s;
}
.soff:hover {
    color: var(--pink);
}

/* ════════════════════════════════════════
   ACCESSIBILITY & RESPONSIVE
   ════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

@media (max-width: 600px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .hd-right {
        width: 100%;
        justify-content: space-between;
    }
    .site-footer {
        flex-direction: column;
        text-align: center;
    }
}
