@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;
    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 (sakura) ─── */
html[data-theme="light"] {
    --bg: #fdf7fb;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.78);
    --text: #1a0f23;
    --text-secondary: #3f2d52;
    --text-tertiary: #6b5b85;
    --text-quaternary: #b9a8cf;
    --accent: #db2777;
    --accent-hover: #be185d;
    --accent-light: rgba(219, 39, 119, 0.08);
    --link: #c026d3;
    --link-hover: #a21caf;
    --border: rgba(26, 15, 35, 0.10);
    --hover-bg: rgba(219, 39, 119, 0.06);
    --shadow-sm: 0 1px 3px rgba(26, 15, 35, 0.05);
    --shadow-md: 0 8px 30px rgba(219, 39, 119, 0.10);
    --shadow-lg: 0 16px 50px rgba(167, 139, 250, 0.18);
    --code-bg: rgba(167, 139, 250, 0.10);
    --pill-bg: var(--accent);
    --pill-text: #ffffff;
    --footer-bg: #1a0f23;
    --footer-text: #fdf7fb;
    --footer-text-dim: rgba(253, 247, 251, 0.55);
    --blob-1: rgba(244, 114, 182, 0.28);
    --blob-2: rgba(167, 139, 250, 0.22);
}

/* ─── Dark Mode ─── */
html[data-theme="dark"] {
    --bg: #0b1220;
    --bg-secondary: #121b2e;
    --bg-card: rgba(18, 27, 46, 0.6);
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-quaternary: #5b6b86;
    --accent: #93c5fd;
    --accent-hover: #bfdbfe;
    --accent-light: rgba(147, 197, 253, 0.12);
    --link: #93c5fd;
    --link-hover: #bfdbfe;
    --border: rgba(148, 163, 184, 0.14);
    --hover-bg: rgba(148, 163, 184, 0.06);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 50px rgba(0, 0, 0, 0.5);
    --code-bg: rgba(148, 163, 184, 0.08);
    --pill-bg: #93c5fd;
    --pill-text: #0b1220;
    --footer-bg: #0b1220;
    --footer-text: #f1f5f9;
    --footer-text-dim: rgba(241, 245, 249, 0.4);
    --blob-1: rgba(59, 130, 246, 0.22);
    --blob-2: rgba(99, 102, 241, 0.18);
}

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 (a la elysiajs.com).
   The new theme layer is masked through a transparent GIF of a dancing
   character — she scales in, dances for most of the animation, then
   explodes outward to fill the screen. */
::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);
}

/* ═══════════════════════════════════════
   STATIC BACKGROUND — soft white/blue
   ═══════════════════════════════════════ */

.bg-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background:
        radial-gradient(1200px 800px at 12% -10%, var(--blob-1), transparent 60%),
        radial-gradient(900px 700px at 110% 110%, var(--blob-2), transparent 55%),
        var(--bg);
}

.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.7;
}

.bg-blob-1 {
    width: 42vmax;
    height: 42vmax;
    top: -12vmax;
    left: -10vmax;
    background: var(--blob-1);
}

.bg-blob-2 {
    width: 36vmax;
    height: 36vmax;
    bottom: -14vmax;
    right: -8vmax;
    background: var(--blob-2);
}

.bg-grain {
    position: absolute;
    inset: 0;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px;
    pointer-events: none;
}

html[data-theme="dark"] .bg-grain { opacity: 0.04; }

/* ═══════════════════════════════════════
   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)
   ═══════════════════════════════════════ */

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    padding: 24px 24px 60px;
}

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

.home-page .avatar {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-secondary);
    box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
    transition: transform var(--transition-spring), box-shadow var(--transition-spring);
    margin-bottom: 24px;
}

.home-page .avatar:hover {
    transform: scale(1.06) rotate(-2deg);
    box-shadow: 0 0 0 2px var(--accent), 0 20px 60px var(--accent-light), var(--shadow-lg);
}

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

@media (max-width: 640px) {
    .hero-name { font-size: 2.5rem; }
}

.hero-aka {
    color: var(--text-tertiary);
    font-size: 15px;
    margin-bottom: 28px;
    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: 16px;
    text-align: left;
}

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

.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;
    justify-content: center;
    gap: 28px;
    flex-wrap: wrap;
    margin-bottom: 9px;
}

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

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

.link-dot { display: none; }


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

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 20px 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;
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    background: linear-gradient(to bottom, var(--bg), color-mix(in srgb, var(--bg) 60%, transparent) 60%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
    mask-image: linear-gradient(to bottom, #000 55%, transparent);
}

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

.header-logo {
    font-family: var(--font-serif);
    font-size: 20px;
    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: 38px;
    height: 38px;
}

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

@media (min-width: 641px) {
    main:not(.hero) { padding: 180px 32px 120px; }
    .site-header { padding: 28px 40px; }
}

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

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

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

h2 {
    font-family: var(--font-serif);
    font-size: 1.625rem;
    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: 20px;
    line-height: 1.75;
    font-size: 16px;
}

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

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

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

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

/* ─── Projects ─── */
.projects { margin-bottom: 48px; }

.projects h2 {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.project {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.project a {
    color: var(--text);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 3px;
}

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

.page-title {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 400;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
    color: var(--text);
}

/* ─── Badges ─── */
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 40px; }
.badges img { width: 88px; height: 31px; image-rendering: pixelated; transition: transform var(--transition); border-radius: 4px; }
.badges img:hover { transform: scale(1.05); }

/* ─── GitHub section ─── */
.graph-label { display: block; font-size: 13px; color: var(--text-tertiary); margin-bottom: 8px; font-weight: 500; }
.github-section a { display: block; text-decoration: none; }
.contrib-graph { width: 100%; height: auto; border-radius: 8px; }

/* ─── Projects page ─── */
.projects-list { margin-top: 32px; }

.project {
    margin-bottom: 4px;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-radius: 12px;
    transition: all var(--transition);
}

.project:hover { background: var(--hover-bg); }

.project h2 {
    font-family: var(--font-sans);
    font-size: 15px; font-weight: 600; color: var(--text);
    text-transform: none; letter-spacing: -0.01em; margin-bottom: 4px;
}

.project p { font-size: 14px; color: var(--text-tertiary); margin-bottom: 0; margin-top: 2px; }

.project-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

.tag {
    font-size: 11px; padding: 3px 10px;
    background: var(--accent-light); color: var(--accent);
    border-radius: 99px; border: none; font-weight: 500;
}

.project-links { display: flex; gap: 16px; }
.project-links a { font-size: 13px; font-weight: 500; }

.project-title { font-size: 15px; font-weight: 600; color: var(--text); text-decoration: none; }
.project-title:hover { text-decoration-color: var(--text); opacity: 1; }

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

.home-footer {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    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: 32px 24px 28px;
    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 {
    color: var(--text-tertiary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: all var(--transition);
}

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

/* ═══════════════════════════════════════
   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 */
.home-page .avatar { animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both; }
.hero-name { animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both; }
.hero-aka { animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both; }
.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-child(2 of .hero-bio) { animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.42s both; }
.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-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: trim blur for GPU, tighten spacing */
@media (max-width: 768px) {
    .bg-blob { filter: blur(70px); }
    .bg-blob-1 { width: 90vw; height: 90vw; }
    .bg-blob-2 { width: 80vw; height: 80vw; }
    .bg-grain { display: none; }

    .hero-links {
        margin-bottom: 4px;
        gap: 20px;
    }

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

    .home-footer {
        bottom: 12px;
        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;
    }
}
