/* ===== CSS Custom Properties (Theme) ===== */
:root {
    /* Dark theme (default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-header: rgba(10, 10, 15, 0.85);
    --bg-nav: linear-gradient(160deg, #0a0a0f 0%, #1a0a0f 50%, #0a0a0f 100%);
    --text-primary: #e0e0e8;
    --text-secondary: rgba(200, 200, 210, 0.7);
    --text-muted: rgba(200, 200, 210, 0.4);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(220, 20, 60, 0.25);
    --accent: #dc143c;
    --accent-dark: #8b0000;
    --glow-accent: rgba(139, 0, 0, 0.15);
    --hamburger-color: #d4d4d4;
    --hero-overlay-top: rgba(10, 10, 15, 0.3);
    --hero-overlay-mid: rgba(10, 10, 15, 0.1);
    --hero-overlay-low: rgba(10, 10, 15, 0.5);
    --hero-overlay-bot: rgba(10, 10, 15, 0.95);
    --logo-brightness: brightness(3.0);
    --card-shadow: 0 8px 32px rgba(139, 0, 0, 0.15);
    --page-top-bg: rgba(20, 20, 30, 0.8);
    --logo-opacity: 0.5;
    --sns-color: rgba(200, 200, 210, 0.6);
    --particle-opacity-base: 0.05;
}

[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #eaeaee;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --bg-header: rgba(255, 255, 255, 0.85);
    --bg-nav: linear-gradient(160deg, #f5f5f7 0%, #fff0f0 50%, #f5f5f7 100%);
    --text-primary: #1a1a2e;
    --text-secondary: rgba(30, 30, 50, 0.65);
    --text-muted: rgba(30, 30, 50, 0.35);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(220, 20, 60, 0.2);
    --accent: #b01030;
    --accent-dark: #8b0000;
    --glow-accent: rgba(139, 0, 0, 0.08);
    --hamburger-color: #333;
    --hero-overlay-top: rgba(245, 245, 247, 0.15);
    --hero-overlay-mid: rgba(245, 245, 247, 0.0);
    --hero-overlay-low: rgba(245, 245, 247, 0.4);
    --hero-overlay-bot: rgba(245, 245, 247, 0.95);
    --logo-brightness: brightness(3.0);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --page-top-bg: rgba(255, 255, 255, 0.85);
    --logo-opacity: 0.7;
    --sns-color: rgba(60, 60, 80, 0.5);
    --particle-opacity-base: 0.08;
}

/* ===== Base Reset & Theme ===== */
html {
    scroll-behavior: smooth;
    font-family: "Inter", "Meiryo", "Yu Gothic Medium", "游ゴシック Medium", YuGothic, "游ゴシック体", "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", sans-serif;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.5s ease, color 0.5s ease;
}

.sawarabi-mincho-regular {
    font-family: "Sawarabi Mincho", "Meiryo", "Yu Gothic Medium", "游ゴシック Medium", YuGothic, "游ゴシック体", "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", serif;
    font-style: normal;
}

/* ===== Scroll Animations ===== */
.scroll_up {
    transition: 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateY(40px);
    opacity: 0;
}

.scroll_up.on {
    transform: translateY(0);
    opacity: 1.0;
}

.scroll_left {
    transition: 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateX(-40px);
    opacity: 0;
}

.scroll_left.on {
    opacity: 1.0;
    transform: translateX(0);
}

.scroll_right {
    transition: 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateX(40px);
    opacity: 0;
}

.scroll_right.on {
    opacity: 1.0;
    transform: translateX(0);
}

/* Fade-in animation for sections */
.fade-in-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-in-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Header ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1100;
    overflow: visible;
    padding-top: 0;
}

.header a {
    opacity: 1;
    float: left;
    color: var(--text-primary);
    text-align: center;
    padding: 0;
    text-decoration: none;
    font-size: 18px;
    line-height: 25px;
    border-radius: 4px;
    transition: opacity 0.4s ease;
}

.header a.logo {
    padding-right: 10px;
    padding-left: 20px;
}

.header a.logo img {
    filter: var(--logo-brightness);
    transition: filter 0.5s ease;
}

.header a:hover {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.header__container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: inherit;
    background-color: var(--bg-header);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    margin-right: auto;
    margin-left: auto;
    padding: 10px 0;
    transition: all 0.4s ease;
}

.header__container.transparent {
    background-color: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom-color: transparent;
}

.header__container.menu-open {
    background-color: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom-color: transparent;
}

.header__container.menu-open a.logo {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* ===== Hamburger Menu (Modern Rounded) ===== */
.hamburger {
    width: 44px;
    height: 44px;
    right: 20px;
    position: relative;
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    background-color: transparent;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: background-color 0.3s ease;
}

.hamburger:hover {
    background-color: var(--bg-card);
}

.hamburger span {
    position: relative;
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--hamburger-color);
    border-radius: 2px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.hamburger span::before,
.hamburger span::after {
    content: "";
    position: absolute;
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--hamburger-color);
    border-radius: 2px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.hamburger span::before {
    top: -7px;
    width: 16px;
    right: 0;
}

.hamburger span::after {
    bottom: -7px;
    width: 12px;
    right: 0;
}

.hamburger:hover span::before,
.hamburger:hover span::after {
    width: 22px;
}

/* Open state */
.hamburger.open span {
    background-color: transparent;
}

.hamburger.open span::before {
    top: 0;
    width: 22px;
    transform: rotate(45deg);
    background-color: var(--accent);
}

.hamburger.open span::after {
    bottom: 0;
    width: 22px;
    transform: rotate(-45deg);
    background-color: var(--accent);
}

/* ===== Theme Toggle Button ===== */
.theme-toggle {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    background: var(--page-top-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.4s ease;
    padding: 0;
    color: var(--text-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.theme-toggle:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--glow-accent);
    transform: scale(1.1);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

/* ===== Full-screen Nav Overlay ===== */
.nav {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg-nav);
    color: var(--text-primary);
    text-align: center;
    line-height: 50px;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.nav.open {
    opacity: 1;
    visibility: visible;
}

ul.nav__list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
}

.nav__list li {
    margin-top: 30px;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.nav.open .nav__list li {
    opacity: 1;
    transform: translateX(0);
}

.nav.open .nav__list li:nth-child(1) {
    transition-delay: 0.1s;
}

.nav.open .nav__list li:nth-child(2) {
    transition-delay: 0.18s;
}

.nav.open .nav__list li:nth-child(3) {
    transition-delay: 0.26s;
}

.nav.open .nav__list li:nth-child(4) {
    transition-delay: 0.34s;
}

.nav__list li a {
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 300;
    text-decoration: none;
    position: relative;
    padding-bottom: 6px;
    transition: color 0.3s ease;
    letter-spacing: 0.08em;
}

.nav__list li a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent));
    transition: width 0.3s ease;
}

.nav__list li a:hover {
    color: var(--accent);
}

.nav__list li a:hover::after {
    width: 100%;
}

.nav__item {
    margin: 0;
    position: relative;
}

.nav__inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.nav__footer {
    margin-top: 50px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
    transition-delay: 0.5s;
}

.nav.open .nav__footer {
    opacity: 1;
    transform: translateY(0);
}

.nav__sns {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;
}

.nav__sns a {
    float: none !important;
    font-size: 24px !important;
    color: var(--text-secondary) !important;
    transition: color 0.3s ease, transform 0.3s ease;
}

.nav__sns a:hover {
    color: var(--accent) !important;
    transform: scale(1.2);
}

.nav__copy {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ===== Page Top Button ===== */
.page-top {
    z-index: 998;
    transition: all 0.5s ease;
    opacity: 0;
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--page-top-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    text-align: center;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.page-top:hover {
    box-shadow: 0 0 20px var(--glow-accent);
    border-color: var(--accent);
}

.page-top a {
    text-decoration: none;
    display: block;
    width: 100%;
    height: 100%;
}

.page-top a:before {
    content: "↑";
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: var(--accent);
    line-height: 44px;
}

/* ===== Hero Section (.top) ===== */
.top {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.top::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
            var(--hero-overlay-top) 0%,
            var(--hero-overlay-mid) 40%,
            var(--hero-overlay-low) 80%,
            var(--hero-overlay-bot) 100%);
    z-index: 1;
    pointer-events: none;
    transition: background 0.5s ease;
}

.top h1 {
    position: absolute;
    color: white;
    z-index: 2;
    font-size: 3rem;
    letter-spacing: 0.15em;
    text-shadow: 0 0 40px rgba(139, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.6);
    animation: heroTextIn 1.2s ease-out;
    text-align: center;
    padding: 0 20px;
    width: 90%;
    max-width: 1200px;
}

@keyframes heroTextIn {
    from {
        opacity: 0;
        transform: translateY(20px);
        letter-spacing: 0.3em;
    }

    to {
        opacity: 1;
        transform: translateY(0);
        letter-spacing: 0.15em;
    }
}

.top img {
    object-fit: cover;
    height: 100%;
    width: 100%;
}

/* ===== SNS Links ===== */
.sns {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

.sns a {
    text-decoration: none;
    color: var(--sns-color);
    font-size: 32px;
    margin: 20px 14px;
    transition: all 0.4s ease;
    position: relative;
}

.sns a:hover {
    transform: translateY(-3px);
}

/* YouTube */
.sns a:nth-child(1):hover {
    color: #ff0000;
    filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.4));
}

/* Twitter/X */
.sns a:nth-child(2):hover {
    color: #1da1f2;
    filter: drop-shadow(0 0 10px rgba(29, 161, 242, 0.4));
}

/* GitHub */
.sns a:nth-child(3):hover {
    color: var(--text-primary);
    filter: drop-shadow(0 0 10px rgba(100, 100, 100, 0.3));
}

/* ===== Copyright ===== */
.copyright h5 {
    text-align: center;
    font-size: 14px;
    font-weight: normal;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    padding-bottom: 30px;
}

/* ===== Logo Bottom ===== */
.logo-bottom {
    margin-top: 40px;
}

.logo-bottom p {
    text-align: center;
}

.logo-bottom img {
    width: 180px;
    margin: auto;
    opacity: var(--logo-opacity);
    transition: opacity 0.4s ease, filter 0.5s ease;
    filter: var(--logo-brightness);
}

.logo-bottom:hover img {
    opacity: 0.9;
}

/* ===== Section Divider ===== */
.section-divider {
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent));
    margin: 0 auto 2em;
    border: none;
    border-radius: 1px;
}

/* ===== Glassmorphism Card Utility ===== */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    transition: all 0.4s ease;
}

.glass-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    box-shadow: var(--card-shadow);
}

/* ===== Background Canvas ===== */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    display: block;
}

@media (max-width: 500px) {
    .top h1 {
        font-size: 1.8rem;
        letter-spacing: 0.1em;
        line-height: 1.4;
    }

    .nav__list li a {
        font-size: 1.6rem;
    }
}

/* ===== Theme-aware Specifics ===== */
.notices h2 {
    color: var(--text-primary);
}

.tool h1,
.notice h1,
.first-intro h1,
.second-intro h1,
.first-index h1,
.projects h1 {
    color: var(--text-primary);
}

.projects div.project-contents a {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.projects div.project-contents a h3 {
    color: var(--text-primary);
}

.projects div.project-contents a p {
    color: var(--text-secondary);
}