@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:wght@400;500;600&display=swap');

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

html {
    overflow-x: clip;
    overflow-y: scroll;
    width: 100%;
    max-width: 100%;
    scroll-behavior: smooth;
}

body {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
}

:root {
    --transition: 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
    --font-mono: 'SF Mono', ui-monospace, 'Cascadia Code', Monaco, monospace;
}

/* ─── Light Mode ─── */
html[data-theme="light"] {
    --bg: #fbfbfa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text: #111110;
    --text-secondary: #3c3c3a;
    --text-tertiary: #6e6e6a;
    --text-quaternary: #9b9b96;
    --accent: #111110;
    --accent-hover: #000000;
    --accent-light: rgba(17, 17, 16, 0.06);
    --link: #111110;
    --link-hover: #000000;
    --border: rgba(17, 17, 16, 0.13);
    --hover-bg: rgba(17, 17, 16, 0.04);
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --code-bg: rgba(17, 17, 16, 0.05);
}

/* ─── Dark Mode ─── */
html[data-theme="dark"] {
    --bg: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #0b0b0b;
    --text: #ebebe9;
    --text-secondary: #b8b8b4;
    --text-tertiary: #8a8a85;
    --text-quaternary: #5f5f5b;
    --accent: #ebebe9;
    --accent-hover: #ffffff;
    --accent-light: rgba(235, 235, 233, 0.08);
    --link: #ebebe9;
    --link-hover: #ffffff;
    --border: rgba(235, 235, 233, 0.13);
    --hover-bg: rgba(235, 235, 233, 0.05);
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --code-bg: rgba(235, 235, 233, 0.07);
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    position: relative;
}

/* Fallback for browsers without View Transitions: animate body bg/color */
body {
    transition: background-color 0.8s cubic-bezier(0.65, 0, 0.35, 1),
                color 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

/* View Transitions API: dancing-girl mask reveal */
::view-transition-group(root) {
    animation-timing-function: cubic-bezier(0.7, 0, 0.84, 0);
    z-index: 100;
}
::view-transition-old(root),
::view-transition-new(root) {
    animation: theme-scale 1.75s cubic-bezier(0.7, 0, 0.84, 0) both;
    mix-blend-mode: normal;
}
::view-transition-new(root) {
    -webkit-mask: url(shigure-ui-smol.gif) 50% / 0 no-repeat;
    mask: url(shigure-ui-smol.gif) 50% / 0 no-repeat;
}

@keyframes theme-scale {
    0%   { -webkit-mask-size: 0;        mask-size: 0; }
    10%  { -webkit-mask-size: 25vmax;   mask-size: 25vmax; }
    90%  { -webkit-mask-size: 25vmax;   mask-size: 25vmax; }
    100% { -webkit-mask-size: 750vmax;  mask-size: 750vmax; }
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) { animation: none; }
    ::view-transition-new(root) { -webkit-mask: none; mask: none; }
}

::selection {
    background: var(--accent-light);
    color: var(--text);
}

/* ═══════════════════════════════════════
   THEME TOGGLE (floating)
   ═══════════════════════════════════════ */

.theme-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 200;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    backdrop-filter: blur(20px) saturate(140%);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.theme-toggle:active { transform: translateY(0) scale(0.96); }

html[data-theme="light"] .moon-icon { display: none; }
html[data-theme="dark"] .sun-icon { display: none; }

/* ═══════════════════════════════════════
   HOMEPAGE HERO (single screen)
   ═══════════════════════════════════════ */

body.home-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.hero {
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding: 36px 24px 0;
}

.hero-content {
    max-width: 560px;
    width: 100%;
    text-align: left;
}

.hero-id {
    display: flex;
    align-items: center;
    gap: 17px;
    margin-bottom: 30px;
}

.avatar-frame {
    width: 72px;
    height: 72px;
    aspect-ratio: 1 / 1;
    flex: none;
    border-radius: 9px;
    overflow: hidden;
    position: relative;
}

.home-page .avatar {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.45s ease;
}

.home-page .avatar.is-swapping { opacity: 0; }

.hero-name {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: -0.03em;
    line-height: 1.0;
    margin-bottom: 4px;
    color: var(--text);
}

@media (max-width: 640px) {
    .hero-name { font-size: 2.1rem; }
    .hero-id { gap: 13px; }
    .avatar-frame { width: 62px; height: 62px; border-radius: 8px; }
}

.hero-aka {
    color: var(--text-tertiary);
    font-size: 15px;
    margin-bottom: 0;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: lowercase;
}

.hero-bio {
    color: var(--text-secondary);
    font-size: 15.5px;
    line-height: 1.7;
    margin-bottom: 15px;
    text-align: left;
}

.hero-bio:last-of-type {
    margin-bottom: 26px;
}

.hero-bio a {
    color: var(--text);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 3px;
    text-decoration-thickness: 1.5px;
    transition: text-decoration-color var(--transition);
}

.hero-bio a:hover {
    text-decoration-color: var(--text);
}

/* ─── Hero links ─── */
.hero-links {
    display: flex;
    align-items: center;
    gap: 26px;
    flex-wrap: wrap;
    margin-bottom: 9px;
}

.hero-links a {
    font-size: 15.5px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: color var(--transition);
}

.hero-links a:hover {
    color: var(--text);
    opacity: 1;
}

/* ═══════════════════════════════════════
   LAYOUT (inner pages)
   ═══════════════════════════════════════ */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 9px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background: var(--bg);
}

.site-header > * {
    pointer-events: auto;
}

.header-logo {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 400;
    font-style: italic;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: opacity var(--transition);
}

.header-logo:hover { opacity: 0.5; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Inner page theme toggle (inside header) */
.site-header .theme-toggle {
    position: static;
    width: 30px;
    height: 30px;
}

main:not(.hero) {
    max-width: 640px;
    margin: 0 auto;
    padding: 66px 24px 44px;
    position: relative;
    z-index: 1;
}

@media (min-width: 641px) {
    main:not(.hero) { padding: 78px 32px 52px; }
    .site-header { padding: 11px 40px; }
}

/* ═══════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════ */

h1 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 400;
    letter-spacing: -0.03em;
    line-height: 1.0;
    margin-bottom: 8px;
    color: var(--text);
}

@media (max-width: 640px) {
    h1 { font-size: 2rem; }
}

h2 {
    font-family: var(--font-serif);
    font-size: 1.45rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 10px;
    color: var(--text);
}

h3 {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    color: var(--text);
}

p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.7;
    font-size: 15.5px;
}

a {
    color: var(--link);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--link-hover);
    opacity: 1;
}

/* Links inside prose carry an underline */
main p a {
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    transition: text-decoration-color var(--transition);
}
main p a:hover { text-decoration-color: var(--text); }

/* ─── Back link ─── */
.back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 18px;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: color var(--transition);
}

.back:hover { color: var(--text); opacity: 1; }

/* ═══════════════════════════════════════
   BLOG (list + post)
   ═══════════════════════════════════════ */

.blog-header {
    animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.blog-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 400;
    font-style: italic;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
    line-height: 1.0;
}

@media (max-width: 640px) {
    .blog-title { font-size: 2rem; }
}

.blog-subtitle {
    color: var(--text-tertiary);
    font-size: 15px;
    margin-bottom: 0;
    line-height: 1.6;
}

.blog-list {
    margin-top: 34px;
}

.blog-post {
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}

.blog-post:first-child {
    border-top: 1px solid var(--border);
}

.blog-post:hover .blog-post-title {
    color: var(--accent);
}

.blog-date {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
    font-weight: 400;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-family: var(--font-sans);
}

.blog-post h2 {
    margin: 0;
    font-family: var(--font-serif);
    font-weight: 400;
}

.blog-post a {
    text-decoration: none;
    color: var(--text);
    font-size: 1.375rem;
    letter-spacing: -0.02em;
    transition: color var(--transition);
    line-height: 1.25;
    display: block;
}

.blog-post a:hover { opacity: 1; }

@media (min-width: 641px) {
    .blog-title { font-size: 2.5rem; }
    .blog-post a { font-size: 1.35rem; }
    .blog-post { padding: 21px 0; }
}

/* ═══════════════════════════════════════
   BLOG POST ARTICLE TYPOGRAPHY
   ═══════════════════════════════════════ */

article h1 {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin-bottom: 10px;
    color: var(--text);
    animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

@media (max-width: 640px) {
    article h1 { font-size: 1.7rem; }
}

.post-meta {
    color: var(--text-tertiary);
    font-size: 13.5px;
    margin-bottom: 36px;
    font-weight: 400;
    letter-spacing: 0.02em;
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.post-content {
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

article p, .post-content p {
    color: var(--text-secondary);
    font-size: 17px;
    line-height: 1.8;
    margin-bottom: 24px;
}

article h2, article h3, .post-content h2, .post-content h3 {
    font-family: var(--font-sans);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-top: 38px;
    margin-bottom: 12px;
}

article img, .post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 28px 0;
}

/* Code blocks */
pre {
    padding: 20px 24px;
    margin: 24px 0;
    overflow-x: auto;
    border-radius: 12px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    max-width: 100%;
    width: 100%;
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--text);
}

code {
    font-family: var(--font-mono);
    font-size: 13.5px;
}

:not(pre) > code {
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--code-bg);
}

/* ═══════════════════════════════════════
   HOME FOOTER (location + live clock)
   ═══════════════════════════════════════ */

.home-footer {
    width: 100%;
    max-width: 608px;
    margin: 0 auto;
    margin-bottom: auto;
    padding: 26px 24px 30px;
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--text);
    letter-spacing: 0.01em;
    animation: fadeIn 1s ease 0.8s both;
    pointer-events: none;
}

.footer-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-quaternary);
    flex-shrink: 0;
}

.footer-time {
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════
   FOOTER (inner pages)
   ═══════════════════════════════════════ */

footer:not(.home-footer) {
    padding: 8px 24px 32px;
    margin-top: 0;
    position: relative;
    z-index: 1;
    background: transparent;
}

.footer-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-credit {
    font-size: 14px;
    color: var(--text-tertiary);
    font-family: var(--font-serif);
    font-style: italic;
}

.footer-credit a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-credit a:hover { color: var(--text); opacity: 1; }

.footer-links {
    display: flex;
    gap: 16px;
    align-items: center;
}

.footer-links a {
    font-size: 13.5px;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover { color: var(--text); opacity: 1; }

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Homepage hero stagger */
.hero-id { animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.12s both; }
.hero-bio:nth-of-type(1), .hero-bio:nth-child(1 of .hero-bio) { animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both; }
.hero-bio:nth-of-type(2), .hero-bio:nth-child(2 of .hero-bio) { animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.42s both; }
.hero-bio:nth-of-type(3), .hero-bio:nth-child(3 of .hero-bio) { animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.49s both; }
.hero-bio:nth-of-type(4), .hero-bio:nth-child(4 of .hero-bio) { animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.56s both; }
.hero-links { animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.6s both; }
.theme-toggle { animation: fadeIn 1s ease 0.5s both; }

/* Inner page animations */
.site-header { animation: fadeIn 1s ease 0.2s both; }

/* Blog list stagger */
.blog-post { animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
.blog-post:nth-child(1) { animation-delay: 0.1s; }
.blog-post:nth-child(2) { animation-delay: 0.18s; }
.blog-post:nth-child(3) { animation-delay: 0.26s; }
.blog-post:nth-child(4) { animation-delay: 0.34s; }
.blog-post:nth-child(5) { animation-delay: 0.42s; }
.blog-post:nth-child(6) { animation-delay: 0.5s; }
.blog-post:nth-child(7) { animation-delay: 0.58s; }
.blog-post:nth-child(8) { animation-delay: 0.66s; }

footer { animation: fadeIn 0.8s ease 0.8s both; }

/* Mobile: tighten spacing */
@media (max-width: 768px) {
    .hero { padding-top: 40px; }

    .hero-links {
        margin-bottom: 4px;
        column-gap: 13px;
        row-gap: 9px;
    }

    .hero-links a {
        font-size: 15px;
    }

    .home-footer {
        padding: 24px 24px 32px;
        gap: 6px;
        font-size: 12px;
    }

    .theme-toggle {
        top: 16px;
        right: 16px;
        width: 38px;
        height: 38px;
    }
}

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