:root {
    --bg: #faf6f0;
    --bg-card: #ffffff;
    --text: #3c2f2f;
    --text-muted: #7a6a5e;
    --border: #e8ddd0;
    --accent: #8b7355;
    --accent-bold: #8b2020;
    --header-bg: #3c2f2f;
    --header-text: #faf6f0;
    --font-sans:
        -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
        "Noto Sans JP", sans-serif;
    --fs-xs: 0.875rem;
    --fs-sm: 1rem;
    --fs-md: 1.2rem;
    --fs-lg: 1.45rem;
    --fs-xl: 1.65rem;
    --fs-2xl: 2.2rem;
}

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

body {
    font-family:
        "Noto Serif TC", "Noto Serif JP", Georgia, "Times New Roman", serif;
    --maid-bg: none;
    --maid-x: 0px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    min-height: 100vh;
    position: relative;
}

body[data-maid="claudia"]  { --maid-bg: url("/assets/maids/maid-claudia.png"); --maid-x: 10px; }
body[data-maid="codex"]    { --maid-bg: url("/assets/maids/maid-codex.png");   --maid-x: -280px; }
body[data-maid="kokona"]   { --maid-bg: url("/assets/maids/maid-kokona.png");  --maid-x: -40px; }
body[data-maid="kotone"]   { --maid-bg: url("/assets/maids/maid-kotone.png");  --maid-x: -30px; }
body[data-maid="kuroko"]   { --maid-bg: url("/assets/maids/maid-kuroko.png");  --maid-x: -70px; }
body[data-maid="kurumi"]   { --maid-bg: url("/assets/maids/maid-kurumi.png");  --maid-x: -250px; }

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: var(--maid-bg) no-repeat var(--maid-x) 20px / auto 1500px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
    transform: scale(1);
    transform-origin: center 20%;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

body.maid-fading::before {
    opacity: 0;
    transform: scale(1.08);
}

body > * {
    position: relative;
    z-index: 1;
}

/* Header */
.site-header {
    background: var(--header-bg);
    color: var(--header-text);
}

.site-header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
    max-width: 960px;
    margin: 0 auto;
}

.header-left {
    justify-self: start;
    display: flex;
}

.header-back {
    display: flex;
    align-items: center;
    color: var(--header-text);
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    opacity: 0.8;
    padding: 0.7rem 0 0.7rem 1.5rem;
}

.header-back:hover {
    opacity: 1;
}

.header-right {
    justify-self: end;
}

.site-logo {
    height: 1.2em;
    width: auto;
    filter: brightness(0) invert(1);
}

.site-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--header-text);
    text-decoration: none;
    font-size: var(--fs-md);
    font-weight: bold;
    letter-spacing: 0.05em;
    padding: 0.7rem 1.5rem;
}

/* Main */
main {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 10px;
}

/* Hero */
.hero {
    text-align: center;
    margin: 0 auto;
    padding: 3rem;
    filter: drop-shadow(0 0 8px var(--bg)) drop-shadow(0 0 8px var(--bg))
        drop-shadow(0 0 16px var(--bg)) drop-shadow(0 0 16px var(--bg));
}

.hero h1 {
    font-size: var(--fs-2xl);
    color: var(--accent-bold);
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--text-muted);
    font-size: var(--fs-md);
}

@media (max-width: 1500px) {
    .hero {
        margin-top: 100px;
        background: none;
        padding: 3rem 1rem;
    }

    .maid-page {
        margin-top: 130px;
    }
}

/* Blog List (homepage) */
.blog-list {
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    max-width: 720px;
    margin: 2rem auto;
    border: 1px dashed var(--border);
    border-radius: 999px;
    padding: 0.6rem 1rem;
    background: rgb(from var(--bg) r g b / 0.85);
}

.blog-row {
    display: flex;
    align-items: baseline;
    gap: 0.8rem;
}

.blog-row-date {
    white-space: nowrap;
    opacity: 0.3;
}

.blog-row-title {
    flex: 1;
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blog-row-title:hover {
    color: var(--accent-bold);
    text-decoration: underline;
}

.blog-row-action {
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
    white-space: nowrap;
}

.blog-row-action:hover {
    text-decoration: underline;
}

.blog-row-author {
    white-space: nowrap;
    opacity: 0.3;
}

/* Blog Post Page */
.blog-page {
    max-width: 640px;
    margin: 2rem auto;
}

.blog-header {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.blog-avatar {
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: 50%;
    object-fit: cover;
    opacity: 0.7;
}

body:has(.blog-page)::before {
    display: none;
}

.blog-header-meta {
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    opacity: 0.5;
    display: flex;
    gap: 1rem;
}

.blog-header-title {
    font-size: var(--fs-md);
    color: var(--text-muted);
    font-weight: normal;
}

.blog-content {
    font-size: var(--fs-sm);
    line-height: 1.9;
}

.blog-content h2 {
    font-size: var(--fs-md);
    color: var(--accent);
    margin: 2rem 0 0.8rem;
}

.blog-content p {
    margin-bottom: 1rem;
}

.blog-content code {
    font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
    background: rgb(from var(--accent) r g b / 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: var(--fs-xs);
}

.blog-content pre {
    background: var(--header-bg);
    color: var(--header-text);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.blog-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

.blog-content a {
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
}

.blog-content a:hover {
    text-decoration: underline;
}

.blog-content strong {
    color: var(--accent-bold);
}

.blog-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: var(--fs-xs);
}

.blog-content th,
.blog-content td {
    padding: 0.3rem 0.8rem;
    text-align: left;
    border-bottom: 1px dashed var(--border);
}

.blog-content th {
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-weight: normal;
    font-size: var(--fs-xs);
}

.blog-content hr {
    border: none;
    border-top: 1px dashed var(--border);
    margin: 1.5rem 0;
}

.blog-content ol {
    margin: 0.5rem 0 1rem 1.5rem;
}

.blog-content li {
    margin-bottom: 0.3rem;
}

/* Blog Index Page */
.blog-index {
    max-width: 640px;
    margin: 2rem auto;
}

.blog-index-title {
    text-align: center;
    padding: 3rem;
    font-size: var(--fs-md);
    color: var(--text-muted);
    font-weight: normal;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 8px var(--bg)) drop-shadow(0 0 8px var(--bg))
        drop-shadow(0 0 16px var(--bg)) drop-shadow(0 0 16px var(--bg));
}

@media (max-width: 1500px) {
    .blog-index-title {
        margin-top: 100px;
        padding: 3rem 1rem;
    }
}

.blog-index-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.blog-index-list .blog-list {
    max-width: none;
    width: 100%;
    margin: 0;
    position: relative;
    overflow: hidden;
}

.blog-index-list .blog-row {
    text-decoration: none;
    color: inherit;
}

.blog-index-list .blog-row:hover .blog-row-title {
    color: var(--accent-bold);
    text-decoration: none;
}

.blog-index-list .blog-list::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: var(--blog-avatar) no-repeat center / cover;
    opacity: 0;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    border-radius: 0 999px 999px 0;
    mask-image: linear-gradient(to right, transparent, black 30%);
    -webkit-mask-image: linear-gradient(to right, transparent, black 30%);
}

.blog-index-list .blog-list:hover::after {
    opacity: 0.6;
    transform: scale(1.08);
}

.blog-index-list .blog-list:hover .blog-row-author {
    opacity: 0;
    transition: opacity 0.3s ease;
}


.blog-row:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.5) 5%,
        rgba(255, 255, 255, 0.5) 60%,
        transparent
    );
}

.blog-row:focus-visible .blog-row-title {
    color: var(--accent-bold);
}

/* Maid List */
.maid-list {
    display: flex;
    flex-direction: column;
    background: rgb(from var(--bg) r g b / 0.85);
}

/* Shared grid: desktop 4-col, mobile 2-col */
.maid-grid {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-rows: auto auto;
    align-items: baseline;
    gap: 0 0.5rem;
}

.maid-grid .maid-name {
    grid-column: 1;
    grid-row: 1;
}
.maid-grid .maid-traits {
    grid-column: 2;
    grid-row: 1;
}
.maid-grid .maid-en-name {
    grid-column: 4;
    grid-row: 1 / -1;
    align-self: start;
}
.maid-grid .maid-quote {
    grid-column: 1 / -1;
    grid-row: 2;
}

.maid-row {
    padding: 0.8rem 0.5rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px dashed var(--border);
}

.maid-row:first-child {
    border-top: 1px dashed var(--border);
}

.maid-row:hover,
.maid-row.active {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.5) 5%,
        rgba(255, 255, 255, 0.5) 60%,
        transparent
    );
}

.maid-name {
    font-size: var(--fs-md);
    font-weight: bold;
    color: var(--accent);
}

.maid-en-name {
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.maid-row:hover .maid-name,
.maid-row.active .maid-name {
    color: var(--accent-bold);
}

.maid-traits {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.maid-quote {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-style: italic;
}

.maid-page {
    overflow: hidden;
}

body:has(.maid-page)::before,
body:has(.not-found)::before {
    opacity: 0.6;
}

/* Maid Detail */
.maid-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: clamp(0.5rem, 5vw, 4rem);
    box-shadow:
        1px 2px 6px rgba(0, 0, 0, 0.03),
        0 1px 2px rgba(0, 0, 0, 0.02);
    position: relative;
}

.maid-detail::before {
    content: "";
    display: block;
    position: absolute;
    border: 50px solid transparent;
    border-top: 50px solid var(--bg);
    top: -60px;
    right: -65px;
    box-shadow: 0 -7px 6px -9px rgba(0, 0, 0, 0.5);
    transform: rotate(-135deg);
}

.maid-detail::after {
    content: "";
    display: block;
    position: absolute;
    border: 50px solid transparent;
    border-bottom: 50px solid var(--bg);
    bottom: -60px;
    left: -65px;
    box-shadow: 0 7px 6px -9px rgba(0, 0, 0, 0.5);
    transform: rotate(-135deg);
}

.maid-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.maid-header .maid-name {
    font-size: var(--fs-xl);
    color: var(--accent-bold);
}

/* Markdown content */
.maid-content {
    font-family:
        "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
    font-size: var(--fs-xs);
    line-height: 1.7;
}
.maid-content .md-hash {
    opacity: 0.3;
}
.maid-content h1 {
    font-size: var(--fs-md);
    margin: 1.5rem 0 0.8rem;
    color: var(--accent);
}
.maid-content h2 {
    font-size: var(--fs-sm);
    margin: 1.3rem 0 0.6rem;
    color: var(--accent);
}
.maid-content p {
    margin-bottom: 0.8rem;
}
.maid-content ul,
.maid-content ol {
    margin: 0.5rem 0 1rem 0;
    list-style: none;
}
.maid-content li {
    margin-bottom: 0.3rem;
}
.maid-content code {
    background: rgb(from var(--accent) r g b / 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: var(--fs-sm);
}

/* Maid CTA */
.maid-cta {
    font-family: var(--font-sans);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    filter: drop-shadow(0 0 8px var(--bg)) drop-shadow(0 0 8px var(--bg))
        drop-shadow(0 0 16px var(--bg)) drop-shadow(0 0 16px var(--bg));
}

.maid-cta code {
    background: none;
    color: var(--accent-bold);
    padding: 0;
    font-size: var(--fs-xs);
    font-weight: bold;
}

.maid-cta button {
    all: unset;
    color: var(--accent);
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
}

.maid-cta button:hover {
    text-decoration: underline;
}

/* Site Footer */
.site-footer {
    text-align: center;
    padding: 4rem 1.5rem 2rem;
    font-size: var(--fs-xs);
    font-family: var(--font-sans);
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0.4;
}

.site-footer a:hover {
    opacity: 0.6;
}

/* Not Found */
.not-found {
    text-align: center;
    padding: 3rem 1rem;
}

.not-found h1 {
    font-size: var(--fs-lg);
    color: var(--accent);
    margin-bottom: 2rem;
}

.not-found-quote {
    font-size: var(--fs-md);
    font-style: italic;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.not-found-maid {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.not-found-back a {
    color: var(--accent);
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
}

.not-found-back a:hover {
    text-decoration: underline;
}

/* Focus-visible — dark background (header) */
.header-back:focus-visible,
.site-title:focus-visible {
    outline: 2px solid var(--header-text);
    outline-offset: -2px;
}

/* Focus-visible — light background */
.maid-row:focus-visible,
.maid-cta button:focus-visible,
.site-footer a:focus-visible,
.not-found-back a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.maid-row:focus-visible {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.5) 5%,
        rgba(255, 255, 255, 0.5) 60%,
        transparent
    );
}

.maid-row:focus-visible .maid-name {
    color: var(--accent-bold);
}

@media (max-width: 499px) {
    .header-back-text {
        display: none;
    }

    .blog-row-action {
        display: none;
    }
}

@media (max-width: 599px) {
    .maid-grid {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
    }

    .maid-grid .maid-name {
        grid-row: 1;
    }
    .maid-grid .maid-en-name {
        grid-column: 2;
        grid-row: 1;
        opacity: 0.5;
        align-self: center;
    }
    .maid-grid .maid-traits {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    .maid-grid .maid-quote {
        grid-column: 1 / -1;
        grid-row: 3;
    }
}
