/* Mistvillion's Home - global styles
   Font: PT Serif only (full TTF, no subsetting). */

@font-face {
    font-family: "PT Serif";
    src: url("../fonts/PTSerif-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "PT Serif";
    src: url("../fonts/PTSerif-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --ink: #f4f7fb;
    --muted: rgba(244, 247, 251, 0.72);
    --pink: #f7a8c4;
    --page-base: #000;
    --motion-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow-x: hidden;
    font-family: "PT Serif", Georgia, "Times New Roman", serif;
    color: var(--ink);
    background: var(--page-base);
}

a {
    font: inherit;
}

/* Content is visible immediately; only the background fades in once loaded. */
.page {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
}

section:focus {
    outline: none;
}

/* First screen: photo, nav and title block. Everything below sits on black. */
.home {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: flex-end;
    padding: 96px 72px 58px;
}

/* Background image, confined to the first screen. */
.page-bg {
    position: absolute;
    inset: 0;
    z-index: -3;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition:
        opacity 700ms var(--motion-soft),
        transform 1400ms var(--motion-soft);
}

/* Without JS the background simply shows; with JS it waits for load. */
html.js .page-bg:not(.is-loaded) {
    opacity: 0;
    transform: scale(1.02);
}

/* Directional shade: dark where text sits (top band for the nav,
   bottom-left for the title), the rest of the photo stays clear. */
.home::before,
.home::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.home::before {
    z-index: -2;
    background:
        linear-gradient(to bottom, rgba(13, 20, 36, 0.42), rgba(13, 20, 36, 0) 180px),
        radial-gradient(ellipse 85% 75% at 0% 100%, rgba(13, 20, 36, 0.78), rgba(13, 20, 36, 0.38) 45%, rgba(13, 20, 36, 0) 75%),
        linear-gradient(rgba(13, 20, 36, 0.1), rgba(13, 20, 36, 0.1));
}

/* Bottom of the photo dissolves into the black page below. */
.home::after {
    top: auto;
    z-index: -1;
    height: 38%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.2) 30%,
        rgba(0, 0, 0, 0.62) 65%,
        #000
    );
}

/* Nav pinned to the top right of the viewport; the bar itself ignores
   pointer events so only the links are clickable. */
.top-nav {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 20px 60px 20px 40px;
    color: var(--ink);
    pointer-events: none;
}

.top-nav .nav-links {
    pointer-events: auto;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    color: rgba(244, 247, 251, 0.74);
    text-decoration: none;
    white-space: nowrap;
    font: inherit;
    font-size: 1.12rem;
    letter-spacing: 0.03em;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
    transition: color 180ms ease;
}

.nav-link:hover,
.nav-link:focus-visible {
    color: var(--ink);
    outline: none;
}

.nav-link:focus-visible {
    text-decoration: underline;
    text-underline-offset: 6px;
}

/* Current page: pink text. */
.nav-link[aria-current="page"] {
    color: var(--pink);
}

/* Scroll-down hint at the bottom centre of the first screen. */
.scroll-hint {
    position: absolute;
    left: 50%;
    bottom: 22px;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    background: none;
    color: rgba(244, 247, 251, 0.82);
    cursor: pointer;
    transform: translateX(-50%);
    animation: scroll-hint-bounce 1.8s ease-in-out infinite;
}

.scroll-hint::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 14px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translate(-50%, -75%) rotate(45deg);
    filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.5));
}

.scroll-hint:hover,
.scroll-hint:focus-visible {
    color: var(--pink);
    outline: none;
}

@keyframes scroll-hint-bounce {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, 10px); }
}

.title-block {
    display: grid;
    gap: 18px;
}

.site-title {
    margin: 0;
    color: var(--pink);
    font-size: clamp(2.5rem, 4.1vw, 4.3rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: 0.01em;
}

.site-sub {
    max-width: 36em;
    margin: 0;
    color: var(--muted);
    font-size: clamp(1.05rem, 1.55vw, 1.5rem);
    line-height: 1.75;
    letter-spacing: 0.015em;
    text-wrap: pretty;
}

/* Sections below the first screen. */
.content-section {
    display: flex;
    justify-content: center;
    padding: 96px 72px;
}

.content-section + .content-section {
    padding-top: 0;
}

.section-inner,
.profile-content {
    width: min(780px, 100%);
    display: grid;
    gap: 16px;
    justify-items: start;
    text-align: left;
}

.section-title {
    margin: 0;
    color: var(--pink);
    font-size: clamp(2.2rem, 3.4vw, 3.4rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.01em;
}

.profile-text {
    display: grid;
    gap: 1em;
}

.profile-content p {
    max-width: 62ch;
    margin: 0;
    color: rgba(244, 247, 251, 0.86);
    font-size: clamp(1.1rem, 1.6vw, 1.4rem);
    line-height: 1.8;
    letter-spacing: 0.01em;
    text-wrap: pretty;
}

.more-link {
    color: var(--muted);
    text-decoration: none;
    letter-spacing: 0.03em;
    transition: color 180ms ease;
}

.more-link:hover,
.more-link:focus-visible {
    color: var(--ink);
}

/* Post list (Latest writing and Blogs). */
.post-list {
    width: 100%;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.post-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.post-link {
    display: grid;
    padding: 24px 0;
    color: inherit;
    text-decoration: none;
}

.post-text {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.post-title {
    margin: 0;
    color: var(--ink);
    font-size: clamp(1.25rem, 1.8vw, 1.55rem);
    font-weight: 700;
    line-height: 1.35;
    transition: color 180ms ease;
}

.post-link:hover .post-title,
.post-link:focus-visible .post-title {
    color: var(--pink);
}

.post-link:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
}

.post-desc {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    color: rgba(244, 247, 251, 0.56);
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

.post-empty {
    padding: 24px 0;
    color: var(--muted);
}

/* Category tags. */
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    color: rgba(244, 247, 251, 0.82);
    background: transparent;
    font: inherit;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    line-height: 1;
}

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

.category-filter:empty {
    display: none;
}

.category-filter .tag {
    min-height: 32px;
    padding: 0 14px;
    cursor: pointer;
    transition:
        color 180ms ease,
        border-color 180ms ease,
        background-color 180ms ease;
}

.category-filter .tag:hover,
.category-filter .tag:focus-visible {
    border-color: rgba(255, 255, 255, 0.6);
    outline: none;
}

.category-filter .tag[aria-pressed="true"] {
    border-color: var(--ink);
    color: #000;
    background: var(--ink);
}

/* Single post. */
.post-view {
    padding-top: 128px;
}

.post {
    width: min(760px, 100%);
}

.post-header {
    display: grid;
    gap: 16px;
    margin: 28px 0 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.post-header .section-title {
    line-height: 1.25;
}

.post-body {
    color: rgba(244, 247, 251, 0.86);
    font-size: 1.08rem;
    line-height: 1.9;
    overflow-wrap: break-word;
}

.post-body > :first-child {
    margin-top: 0;
}

.post-body p,
.post-body ul,
.post-body ol,
.post-body blockquote,
.post-body pre {
    margin: 0 0 1.25em;
}

.post-body h2,
.post-body h3,
.post-body h4 {
    margin: 2em 0 0.8em;
    color: var(--ink);
    line-height: 1.4;
}

.post-body h2 {
    font-size: 1.5rem;
}

.post-body h3 {
    font-size: 1.25rem;
}

.post-body h4 {
    font-size: 1.08rem;
}

.post-body a {
    color: var(--pink);
    text-underline-offset: 3px;
}

.post-body ul,
.post-body ol {
    padding-left: 1.6em;
}

.post-body li + li {
    margin-top: 0.3em;
}

.post-body blockquote {
    padding-left: 1em;
    border-left: 2px solid rgba(255, 255, 255, 0.24);
    color: var(--muted);
}

.post-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 4px;
}

.post-body code {
    padding: 0.1em 0.35em;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.9em;
}

.post-body pre {
    overflow-x: auto;
    padding: 16px 18px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    line-height: 1.6;
}

.post-body pre code {
    padding: 0;
    background: none;
}

.post-body hr {
    margin: 2.5em 0;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.post-body table {
    width: 100%;
    margin: 0 0 1.25em;
    border-collapse: collapse;
}

.post-body th,
.post-body td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    text-align: left;
}

/* Responsive spacing for phones. */
@media (max-width: 640px) {
    .top-nav {
        padding: 14px 14px 14px 16px;
    }

    .nav-links {
        gap: 2px;
    }

    .nav-link {
        min-height: 32px;
        padding: 0 10px;
        font-size: 1rem;
    }

    .home {
        padding: 88px 24px 30px;
    }

    .content-section {
        padding: 64px 24px;
    }

    .post-view {
        padding-top: 88px;
    }

    .site-title {
        font-size: 2.6rem;
    }

    .site-sub {
        font-size: 1.05rem;
    }

    .section-title {
        font-size: 2.1rem;
    }

    .profile-content p {
        font-size: 1.05rem;
    }

    .post-body {
        font-size: 1rem;
    }
}

@media (max-width: 380px) {
    .nav-link {
        padding: 0 8px;
        font-size: 0.92rem;
    }

    .site-title {
        font-size: 2.2rem;
    }

    .site-sub {
        font-size: 1rem;
    }

    .profile-content p {
        font-size: 1rem;
    }
}

/* Internal page swaps: the unchanged nav makes the root
   cross-fade read as a content-only transition. */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 220ms;
    animation-timing-function: var(--motion-soft);
}

@media (prefers-reduced-motion: reduce) {
    .scroll-hint {
        animation: none;
    }

    .page-bg,
    .nav-link,
    .more-link,
    .post-title,
    .category-filter .tag {
        transition: none !important;
    }

    html.js .page-bg:not(.is-loaded) {
        transform: none;
    }
}
