/* ==========================================================================
   Pages: prose, project pages, posts, home sections, 404
   ========================================================================== */

/* --- Prose (rendered Markdown) ------------------------------------------- */

.prose { color: #d8d5ec; font-size: 1.04rem; line-height: 1.75; }
.prose > * + * { margin-top: 1.15em; }
.prose > :first-child { margin-top: 0; }

.prose .lede { color: var(--text); font-size: clamp(1.1rem, 1.6vw, 1.28rem); line-height: 1.6; }

.prose h2 { margin-top: 2.2em; font-size: clamp(1.5rem, 2.6vw, 1.95rem); color: var(--text); }
.prose h3 { margin-top: 1.8em; font-size: clamp(1.18rem, 2vw, 1.35rem); color: var(--text); }
.prose h4 { margin-top: 1.5em; font-size: 1.05rem; color: var(--text); }
.prose h2 + *, .prose h3 + * { margin-top: 0.7em; }

.prose .heading-anchor {
    margin-left: 0.35em;
    color: var(--text-faint);
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.2s, color 0.2s;
}
.prose :is(h2, h3):hover .heading-anchor, .prose .heading-anchor:focus-visible { opacity: 1; }
.prose .heading-anchor:hover { color: var(--cyan); }

.prose a:not(.heading-anchor):not(.button) {
    color: var(--cyan-soft);
    text-decoration: underline;
    text-decoration-color: rgba(159, 243, 255, 0.35);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: text-decoration-color 0.2s, color 0.2s;
}
.prose a:not(.heading-anchor):not(.button):hover { color: #fff; text-decoration-color: var(--cyan); }

.prose strong { color: var(--text); font-weight: 600; }

.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.45em; }
.prose li > ul, .prose li > ol { margin-top: 0.45em; }
.prose ul li::marker { color: var(--accent); }
.prose ol li::marker { color: var(--text-faint); font-family: var(--font-mono); font-size: 0.9em; }

.prose :not(pre) > code {
    padding: 0.12em 0.4em;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: #f0e6ff;
    font-size: 0.86em;
    overflow-wrap: anywhere;
}

.prose pre {
    margin: 0;
    padding: 34px 20px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #0a0820;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    font-size: 0.86rem;
    line-height: 1.7;
    overflow-x: auto;
    tab-size: 4;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.prose blockquote {
    margin-inline: 0;
    padding: 4px 0 4px 20px;
    border-left: 3px solid var(--accent);
    color: var(--text-muted);
    font-style: italic;
}

.prose hr { height: 1px; margin-block: 2.5em; border: 0; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); }

.prose img { border-radius: var(--radius); border: 1px solid var(--border); }
.prose figure figcaption { margin-top: 10px; color: var(--text-muted); font-size: 0.88rem; text-align: center; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

.prose table, .chart__table table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.prose th, .prose td, .chart__table th, .chart__table td { padding: 11px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th, .chart__table th { color: var(--text); background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.prose tr:last-child td, .chart__table tr:last-child td { border-bottom: 0; }
.prose tbody tr { transition: background-color 0.2s; }
.prose tbody tr:hover { background: var(--surface); }

.prose .katex-display { padding: 8px 0; overflow-x: auto; overflow-y: hidden; }
.prose .katex { font-size: 1.08em; }

.prose .footnotes { margin-top: 3em; color: var(--text-muted); font-size: 0.9rem; }

/* --- Project page -------------------------------------------------------- */

.project-hero {
    position: relative;
    padding-block: clamp(36px, 6vw, 72px) clamp(32px, 5vw, 56px);
    overflow: hidden;
}

.project-hero__glow {
    position: absolute;
    top: -40%; left: 50%;
    width: min(1100px, 140vw);
    aspect-ratio: 1.6;
    transform: translateX(-50%);
    background:
        radial-gradient(ellipse at 35% 50%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 55%),
        radial-gradient(ellipse at 70% 40%, color-mix(in srgb, var(--accent-2) 28%, transparent), transparent 55%);
    filter: blur(40px);
    opacity: 0.55;
    pointer-events: none;
}

.project-hero .container { position: relative; }

.project-hero__head { display: flex; align-items: center; gap: clamp(20px, 3.5vw, 40px); }

.project-hero__icon-wrap { position: relative; flex: none; }
.project-hero__icon-wrap::before {
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 30%;
    background: var(--accent);
    filter: blur(40px);
    opacity: 0.45;
    animation: glow-breathe 5s var(--ease-in-out) infinite alternate;
}

.project-hero__icon {
    position: relative;
    width: clamp(96px, 14vw, 156px);
    height: auto;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.6));
}

.project-hero__meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; color: var(--text-faint); font-size: 0.88rem; }
.project-hero__title { font-size: clamp(2.6rem, 7vw, 4.8rem); letter-spacing: -0.04em; }
.project-hero__tagline { max-width: 52ch; margin-top: 14px; color: var(--text-muted); font-size: clamp(1.02rem, 1.6vw, 1.22rem); }
.project-hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

@media (max-width: 600px) {
    .project-hero__head { flex-direction: column; align-items: start; }
}

.project-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: clamp(32px, 5vw, 72px);
    padding-bottom: clamp(56px, 8vw, 96px);
}

.project-content { min-width: 0; max-width: var(--narrow-w); }

.gallery-section { margin-top: clamp(48px, 7vw, 88px); }
.gallery-section__title { margin-bottom: 24px; font-size: clamp(1.5rem, 2.6vw, 1.95rem); }

/* The gallery may be wider than the prose column on large screens */
@media (min-width: 1100px) {
    .project-content { max-width: none; }
    .project-content > .prose { max-width: var(--narrow-w); }
}

@media (max-width: 1000px) {
    .project-layout { grid-template-columns: minmax(0, 1fr); }
    .project-aside { display: none; }
}

.project-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding-bottom: clamp(56px, 8vw, 96px);
}

.project-nav__link {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px 26px;
    overflow: hidden;
    transition: transform 0.4s var(--ease-out);
}
.project-nav__link:hover { transform: translateY(-3px); }
.project-nav__link--next { align-items: end; text-align: right; }
.project-nav__dir { display: inline-flex; align-items: center; gap: 8px; color: var(--text-faint); font-size: 0.85rem; }
.project-nav__name { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }

@media (max-width: 600px) {
    .project-nav { grid-template-columns: 1fr; }
    .project-nav__name { font-size: 1.15rem; }
}

/* --- Blog ---------------------------------------------------------------- */

.blog-tools { display: flex; gap: 10px; margin-top: 28px; }

.empty {
    padding: 48px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    text-align: center;
}

/* --- Post ---------------------------------------------------------------- */

.post-hero { padding-block: clamp(40px, 7vw, 88px) clamp(24px, 4vw, 40px); }
.post-hero .chips { margin-bottom: 18px; }
.post-hero__title { font-size: clamp(2.2rem, 5.6vw, 3.6rem); letter-spacing: -0.035em; }
.post-hero__lede { margin-top: 18px; color: var(--text-muted); font-size: clamp(1.05rem, 1.6vw, 1.22rem); }

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 0.88rem;
}
.post-meta > span { display: inline-flex; align-items: center; gap: 8px; }
.post-meta [hidden] { display: none; }

.post-cover { margin-bottom: clamp(24px, 4vw, 48px); }
.post-cover img { width: 100%; max-height: 520px; object-fit: cover; border-radius: var(--radius-lg); border: 1px solid var(--border); }

.post-layout {
    display: grid;
    grid-template-columns: minmax(0, var(--narrow-w));
    justify-content: center;
    padding-top: 12px;
}

/* Keep the article centred under the header; the contents sit in the right-hand gutter. */
.post-layout--toc {
    grid-template-columns: minmax(0, 1fr) minmax(0, var(--narrow-w)) minmax(0, 1fr);
    gap: clamp(32px, 4vw, 56px);
}
.post-layout--toc .post-body { grid-column: 2; grid-row: 1; }
.post-layout--toc .post-aside { grid-column: 3; grid-row: 1; max-width: 240px; }

@media (max-width: 1240px) {
    .post-layout--toc { grid-template-columns: minmax(0, var(--narrow-w)); }
    .post-layout--toc .post-body { grid-column: 1; }
    .post-aside { display: none; }
}

.post-footer { padding-block: 48px clamp(56px, 8vw, 96px); }

.post-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-block: 24px;
    border-block: 1px solid var(--border);
}

.like {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 18px 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 600;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s, transform 0.2s;
}
.like:hover:not(:disabled) { color: var(--text); border-color: var(--pink); }
.like:disabled { opacity: 0.6; cursor: default; }
.like__icon { display: grid; transition: transform 0.4s var(--ease-out); }
.like__count { font-family: var(--font-mono); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.like[aria-pressed="true"] { color: var(--pink); border-color: color-mix(in srgb, var(--pink) 60%, transparent); background: color-mix(in srgb, var(--pink) 10%, transparent); }
.like[aria-pressed="true"] .icon { fill: currentColor; }
.like.is-popping .like__icon { animation: heart-pop 0.6s var(--ease-out); }

@keyframes heart-pop {
    0% { transform: scale(1); }
    30% { transform: scale(1.45); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.like__spark {
    position: absolute;
    left: 24px; top: 50%;
    width: 6px; height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: var(--c, var(--pink));
    pointer-events: none;
    animation: spark 0.7s var(--ease-out) forwards;
}

@keyframes spark {
    from { transform: translate(0, 0) scale(1); opacity: 1; }
    to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 32px; }

.post-nav__link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s, background-color 0.2s, transform 0.3s var(--ease-out);
}
.post-nav__link:hover { border-color: var(--border-strong); background: var(--surface); transform: translateY(-2px); }
.post-nav__link span { color: var(--text-faint); font-size: 0.8rem; }
.post-nav__link strong { font-family: var(--font-display); font-weight: 600; }
.post-nav__link--newer { grid-column: 2; text-align: right; }

@media (max-width: 600px) {
    .post-nav { grid-template-columns: 1fr; }
    .post-nav__link--newer { grid-column: auto; }
}

.related { margin-top: 56px; }
.related__title { margin-bottom: 20px; font-size: 1.4rem; }

/* --- Home: about teaser with stacked screenshots ------------------------- */

.about-teaser {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(40px, 6vw, 88px);
}

.about-teaser__copy .prose { margin-block: 20px 24px; color: var(--text-muted); }

.stack { position: relative; aspect-ratio: 4 / 3; }

.stack img {
    position: absolute;
    width: 72%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transition: transform 0.8s var(--ease-out);
}
.stack img:nth-child(1) { left: 0; top: 0; transform: rotate(-6deg); }
.stack img:nth-child(2) { right: 0; top: 18%; transform: rotate(4deg); z-index: 1; }
.stack img:nth-child(3) { left: 12%; bottom: 0; transform: rotate(-1deg); z-index: 2; }
.stack:hover img:nth-child(1) { transform: rotate(-10deg) translate(-12px, -10px); }
.stack:hover img:nth-child(2) { transform: rotate(8deg) translate(14px, -6px); }
.stack:hover img:nth-child(3) { transform: rotate(0deg) translateY(10px); }

@media (max-width: 860px) {
    .about-teaser { grid-template-columns: 1fr; }
    .about-teaser__visual { max-width: 520px; width: 100%; justify-self: center; }
}

/* --- 404 ------------------------------------------------------------------ */

.not-found { padding-block: clamp(40px, 8vw, 96px); text-align: center; }
.not-found__inner { display: flex; flex-direction: column; align-items: center; }
.not-found .page-hero__lede code { padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text); overflow-wrap: anywhere; }
.not-found__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 32px; }
.not-found__projects { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 28px; }

.singularity {
    position: relative;
    width: min(280px, 70vw);
    aspect-ratio: 1;
    margin-bottom: 24px;
}

.singularity__disc {
    position: absolute;
    inset: 30% -10%;
    border-radius: 50%;
    background: conic-gradient(from var(--angle), #fff4d6, #ffb547, #ff4f8b, #8a2be2, #3fb8ff, #fff4d6);
    filter: blur(6px);
    transform: rotateX(72deg);
    animation: border-spin 6s linear infinite;
    mask-image: radial-gradient(ellipse, transparent 30%, #000 42%, #000 60%, transparent 72%);
}

.singularity__ring {
    position: absolute;
    inset: 22%;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(255, 220, 160, 0.9), 0 0 30px 8px rgba(255, 181, 71, 0.7), 0 0 90px 20px rgba(177, 75, 255, 0.5);
    animation: glow-breathe 4s var(--ease-in-out) infinite alternate;
}

.singularity__core {
    position: absolute;
    inset: 24%;
    border-radius: 50%;
    background: radial-gradient(circle, #000 60%, #05040f);
}
