/* CSS Variables */
:root {
    --color-bg-dark: #0b0b0b;
    --color-bg-mid: #111111;
    --color-bg-light: #181818;
    --color-gold: #b8984f;
    --color-gold-dim: #8b7136;
    --color-red: #8d1c1c;
    --color-red-dim: #5c1111;
    --color-white: #f4f4f4;
    --color-gray: #888888;
    --color-blue: #1c3d5a;

    --font-en: 'Cinzel', serif;
    --font-en-sans: 'Bebas Neue', sans-serif;
    --font-jp: 'Noto Serif JP', serif;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--color-bg-dark);
    color: var(--color-white);
    font-family: var(--font-jp);
    line-height: 1.8;
    overflow-x: hidden;
    font-size: 16px;
    font-weight: 300;
}

a {
    color: var(--color-white);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--color-gold);
}

/* モバイルメニューを開いている間は背面をスクロールさせない */
body.nav-open {
    overflow: hidden;
}

/* width / height 属性は読み込み前の領域確保（レイアウトシフト防止）に使うので
   width は auto にせず属性値のまま効かせ、高さだけ比率追従させる。
   ただし max-height を併用する画像は個別に width:auto が必要（下記 .hero-logo-img 参照）。 */
img {
    max-width: 100%;
    height: auto;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-en);
    font-weight: 400;
    letter-spacing: 0.1em;
}

/* Gritty Noise Overlay */
.noise-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.05;
    background-image: url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)"/%3E%3C/svg%3E');
}

/* Layout Classes */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 5%;
}

.section {
    padding: 150px 0;
    position: relative;
}

.section-title {
    text-align: center;
    font-size: 3rem;
    color: var(--color-gold);
    margin-bottom: 80px;
    letter-spacing: 0.2em;
    position: relative;
    text-shadow: 0 0 10px rgba(184, 152, 79, 0.3);
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background-color: var(--color-gold);
}

/* Header & Nav */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background: linear-gradient(to bottom, rgba(11,11,11,0.9) 0%, rgba(11,11,11,0) 100%);
}

.logo-small {
    font-family: var(--font-en);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-gold);
    letter-spacing: 2px;
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
}

.hamburger span {
    display: block;
    width: 30px;
    height: 2px;
    background-color: var(--color-white);
    margin: 6px 0;
    transition: 0.3s;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
    opacity: 0;
}
.hamburger.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100vh;
    background-color: rgba(11,11,11,0.95);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: right 0.5s cubic-bezier(0.77, 0, 0.175, 1);
    backdrop-filter: blur(10px);
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav ul {
    list-style: none;
    text-align: center;
}

.mobile-nav li {
    margin: 20px 0;
}

.mobile-nav a {
    font-family: var(--font-en);
    font-size: 1rem;
    letter-spacing: 0.1em;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    padding-top: 100px;
    padding-bottom: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    top: -5%; left: -5%; width: 110%; height: 110%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    filter: brightness(0.6) contrast(1.2) sepia(0.2) hue-rotate(-10deg);
}

.hero::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(0,0,0,0) 0%, rgba(11,11,11,0.8) 100%);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-logo-img {
    max-width: 80%;
    /* width:auto が無いと、width 属性(3508px)が presentational hint として効いたまま
       max-height だけが高さを縮めるため、ロゴが横に伸びて潰れる */
    width: auto;
    height: auto;
    max-height: 500px;
    margin-bottom: 20px;
    opacity: 0; /* GSAP will animate */
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.8));
}

.hero-titles h2 {
    font-size: 4vw;
    color: var(--color-gold);
    margin-bottom: 15px;
    text-shadow: 0 0 15px rgba(184, 152, 79, 0.5);
    opacity: 0;
}

.hero-titles .subtitle {
    font-family: var(--font-en);
    font-size: 1.2rem;
    letter-spacing: 0.2em;
    color: var(--color-gray);
    margin-bottom: 40px;
    opacity: 0;
}

.enter-btn {
    background-color: transparent;
    border: 1px solid var(--color-gold);
    color: var(--color-gold);
    padding: 15px 40px;
    font-family: var(--font-en);
    font-size: 1.2rem;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: all 0.4s ease;
    opacity: 0;
    position: relative;
    overflow: hidden;
}

.enter-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background-color: var(--color-gold);
    transition: left 0.4s ease;
    z-index: -1;
}

.enter-btn:hover {
    color: var(--color-bg-dark);
}
.enter-btn:hover::before {
    left: 0;
}

.scroll-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    text-align: center;
    font-family: var(--font-en);
    font-size: 0.8rem;
    letter-spacing: 2px;
    opacity: 0.7;
}

.scroll-indicator .line {
    width: 1px;
    height: 60px;
    background-color: var(--color-gold);
    margin: 10px auto 0;
    animation: scrollLine 2s infinite;
}

@keyframes scrollLine {
    0% { transform: scaleY(0); transform-origin: top; }
    50% { transform: scaleY(1); transform-origin: top; }
    50.1% { transform: scaleY(1); transform-origin: bottom; }
    100% { transform: scaleY(0); transform-origin: bottom; }
}

/* News Section */
.news-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 800px;
}

.news-card {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    transition: background-color 0.3s;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
}

.news-card:hover {
    background-color: rgba(255,255,255,0.02);
}

.news-card .date {
    font-family: var(--font-en);
    color: var(--color-gray);
    width: 100px;
}

.news-card .category {
    font-family: var(--font-en-sans);
    padding: 2px 10px;
    margin-right: 20px;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.news-card .category.event { border: 1px solid var(--color-gold); color: var(--color-gold); }
.news-card .category.update { border: 1px solid var(--color-white); color: var(--color-white); }
.news-card .category.world { border: 1px solid var(--color-red); color: var(--color-red); }

.news-card h3 {
    font-family: var(--font-jp);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    flex-grow: 1;
}

/* About Section */
.about-section {
    position: relative;
    text-align: center;
}

/* GSAP が transform でパララックスさせる要素に background-attachment: fixed を
   併用すると、transform が背景の包含ブロックを作り直してしまい
   スクロール開始の瞬間に背景が飛ぶ。パララックスは JS 側に任せる。 */
.about-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    filter: brightness(0.3) grayscale(0.5);
    z-index: 0;
    will-change: transform;
}

.about-content {
    position: relative;
    z-index: 1;
    background-color: rgba(11,11,11,0.7);
    padding: 80px 40px;
    border: 1px solid rgba(184, 152, 79, 0.2);
    backdrop-filter: blur(5px);
}

.about-text p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    opacity: 0;
    transform: translateY(20px);
}

/* Story Section */
.story-text {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 100px;
}

.story-text p {
    margin-bottom: 40px;
    opacity: 0;
}

.subsection-title {
    text-align: center;
    font-size: 2rem;
    color: var(--color-gray);
    margin-bottom: 50px;
}

.timeline {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 100%;
    background-color: rgba(255,255,255,0.2);
}

.timeline-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    opacity: 0;
}

.timeline-item .year {
    width: 45%;
    text-align: right;
    font-family: var(--font-en);
    font-size: 1.5rem;
    color: var(--color-gold);
}

.timeline-item .event {
    width: 45%;
    text-align: left;
    font-size: 1rem;
    border-left: 1px solid var(--color-gold);
    padding-left: 20px;
}

/* Factions Section */
.factions-section {
    display: flex;
    min-height: 100vh;
}

.faction {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
    overflow: hidden;
    cursor: pointer;
    transition: flex 0.5s ease;
}

.faction:hover {
    flex: 1.2;
}

.faction-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    filter: brightness(0.4) contrast(1.2);
    transition: transform 10s ease, filter 0.5s ease;
    z-index: 0;
}

.faction:hover .faction-bg {
    transform: scale(1.05);
    filter: brightness(0.6) contrast(1.2);
}

.faction-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
}
.red-faction .faction-overlay { background: linear-gradient(to top, rgba(141, 28, 28, 0.4), transparent); }
.blue-faction .faction-overlay { background: linear-gradient(to top, rgba(28, 61, 90, 0.4), transparent); }

.faction-content {
    position: relative;
    z-index: 2;
    text-align: center;
    background: rgba(0,0,0,0.6);
    padding: 40px;
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(4px);
    opacity: 0.8;
    transition: opacity 0.3s ease;
}
.faction:hover .faction-content {
    opacity: 1;
}

.faction h2 {
    font-family: var(--font-jp);
    font-size: 2rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
}
.red-faction h2 { color: var(--color-red); }
.blue-faction h2 { color: var(--color-gold); } /* Adjust color as needed */

.faction p {
    font-size: 1rem;
    margin-bottom: 20px;
}

.faction .keywords {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 15px;
    font-family: var(--font-en);
    font-size: 0.9rem;
    color: var(--color-gray);
}

/* Community Section */
.community-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.comm-card {
    background-color: var(--color-bg-mid);
    padding: 40px 30px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.05);
    transition: transform 0.3s ease, border-color 0.3s ease;
    opacity: 0;
    transform: translateY(30px);
}

.comm-card:hover {
    transform: translateY(-10px);
    border-color: var(--color-gold);
}

.comm-card .icon {
    font-family: var(--font-en-sans);
    font-size: 3rem;
    color: var(--color-gold-dim);
    margin-bottom: 20px;
}

.comm-card h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
}

/* World Section */
.world-section {
    position: relative;
    padding: 150px 0;
}
.world-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    filter: brightness(0.2) sepia(0.5) hue-rotate(180deg);
    z-index: 0;
}

.relative { position: relative; z-index: 1; }

.nations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.nation-card {
    background: rgba(11,11,11,0.8);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
}

.nation-card:hover {
    background: rgba(184, 152, 79, 0.1);
    border-color: var(--color-gold);
}

.nation-card h3 {
    font-size: 1.2rem;
    color: var(--color-white);
}

/* Gallery Section: preserve the complete official documents and their colors. */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    padding: 0 5%;
    max-width: 1400px;
    margin: 0 auto;
}
.gallery-item {
    display: block;
    overflow: hidden;
    position: relative;
    opacity: 0;
}
.gallery-document {
    background: #f5f5f5;
    border: 1px solid #555;
    text-decoration: none;
    align-self: start;
}
.gallery-document--dark { background: #171717; }
.gallery-document img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2000 / 1414;
    object-fit: contain;
    filter: none;
    transform: none;
}
.gallery-document:hover img { filter: none; transform: none; }
.gallery-document:focus-visible { outline: 3px solid #efcf77; outline-offset: 4px; }
.gallery-caption {
    display: block;
    padding: 12px 16px;
    background: #202020;
    color: #fff;
    font-size: 1rem;
    text-align: center;
}
@media (max-width: 700px) {
    .gallery-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}

/* Join Section */
.join-section {
    text-align: center;
    background: linear-gradient(to bottom, var(--color-bg-dark), #151515);
}

.join-steps {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 60px;
}

.step {
    background: var(--color-bg-mid);
    padding: 20px 40px;
    border: 1px solid rgba(184, 152, 79, 0.3);
    min-width: 300px;
    position: relative;
    opacity: 0;
}

.step-num {
    font-family: var(--font-en-sans);
    font-size: 2rem;
    color: var(--color-gold-dim);
    position: absolute;
    top: -15px; left: -15px;
    background: var(--color-bg-dark);
    padding: 0 10px;
}

.step-arrow {
    font-size: 2rem;
    color: var(--color-gray);
    margin: 15px 0;
    opacity: 0;
}

.join-btn {
    display: inline-block;
    max-width: 100%;
    text-align: center;
    background-color: var(--color-gold);
    color: var(--color-bg-dark);
    border: none;
    padding: 20px 60px;
    font-family: var(--font-en);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(184, 152, 79, 0.4);
}

.join-btn:hover {
    color: var(--color-bg-dark);
    background-color: var(--color-white);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.6);
}

/* Footer */
.footer {
    background-color: #050505;
    padding: 60px 0 30px;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.footer-logo {
    font-size: 2rem;
    color: var(--color-gray);
    margin-bottom: 20px;
}

.sns-links {
    margin-bottom: 30px;
}

.sns-links a {
    font-family: var(--font-en);
    margin: 0 15px;
    letter-spacing: 1px;
}

.copyright {
    font-family: var(--font-en-sans);
    color: #444;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .factions-section { flex-direction: column; }
    .hero-titles h2 { font-size: 8vw; }
    .timeline::before { left: 20px; }
    .timeline-item { flex-direction: column; align-items: flex-start; padding-left: 40px; }
    .timeline-item .year { text-align: left; margin-bottom: 10px; width: 100%; }
    .timeline-item .event { width: 100%; border-left: none; padding-left: 0; }
}

/* Header Links */
.header-links {
    display: none;
    align-items: center;
    gap: 15px;
    margin-left: auto;
    margin-right: 20px;
}
@media (min-width: 769px) {
    .header-links {
        display: flex;
    }
}
.header-btn {
    color: var(--color-gray);
    font-size: 0.9rem;
    font-family: var(--font-jp);
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
    text-decoration: none;
}
.header-btn:hover {
    color: var(--color-gold);
    border-color: var(--color-gold);
    background: rgba(184, 152, 79, 0.1);
}

/* -----------------------------------------------------------
   background-attachment: fixed はモバイル (iOS Safari / Android)
   では固定されないか極端に重くなり、背景が拡大されたまま
   ガタつく。タッチ端末では通常スクロールに戻す。
   ----------------------------------------------------------- */
@media (max-width: 900px), (hover: none) {
    .world-bg {
        background-attachment: scroll;
    }
}

/* -----------------------------------------------------------
   モーション低減設定 (prefers-reduced-motion) への配慮。
   パーティクル等のループ演出を止め、スクロール演出で
   opacity:0 のままになる要素を確実に表示する。
   ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .gs-fade-up,
    .news-card,
    .comm-card,
    .nation-card,
    .gallery-item,
    .timeline-item,
    .join-steps .step,
    .join-steps .step-arrow,
    .about-text p,
    .story-text p {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Faction detail navigation. */
.faction-detail-link { display:inline-block; margin-top:28px; padding:12px 24px; border:1px solid #d37979; color:#ffe1e1; background:#190c0cc9; font-size:1rem; letter-spacing:.1em; }
.faction-detail-link:hover { color:#fff; background:#7d2222; border-color:#ffc0c0; }
.faction-detail-link:focus-visible { outline:2px solid #ffe1e1; outline-offset:5px; }

/* Glossary entry immediately after the faction introductions. */
.faction-glossary { padding:36px 24px; text-align:center; background:#101923; border-block:1px solid #b8984f55; }
.faction-glossary p { margin-bottom:16px; }
.footer-contact { text-align:center; padding:24px 16px 0; }
.contact-link { display:inline-block; padding:12px 28px; border:1px solid var(--color-gold); border-radius:4px; color:var(--color-white); font:400 1rem var(--font-jp); text-decoration:none; background:#151515; }
.contact-link:hover,.contact-link:focus-visible { background:var(--color-gold); color:#101010; }
/* Identical social buttons and ordering across every page. */
body footer.shared-site-footer { position:relative; z-index:10; padding:48px 0 28px; background:#050505; text-align:center; }
body footer.shared-site-footer .container { width:100%; max-width:1200px; margin:0 auto; padding:0 20px; }
body footer.shared-site-footer .footer-logo { font:400 clamp(1.2rem,4vw,2rem) var(--font-en); color:#aaa; margin:0 0 24px; }
body footer.shared-site-footer .footer-nav { display:flex; flex-wrap:wrap; justify-content:center; gap:12px; margin:0 0 28px; }
body footer.shared-site-footer .footer-nav .footer-btn { display:inline-block; margin:0; padding:10px 18px; font-size:14px; }
body footer.shared-site-footer .sns-links { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; width:100%; max-width:620px; margin:0 auto; }
body footer.shared-site-footer .sns-links .social-button { display:flex; justify-content:center; align-items:center; min-height:52px; min-width:0; padding:12px 8px; margin:0; border:1px solid #707070; border-radius:4px; background:#171717; color:#f4f4f4; font:400 15px/1.6 "Yu Gothic",Meiryo,sans-serif; letter-spacing:0; text-decoration:none; box-sizing:border-box; }
body footer.shared-site-footer .sns-links a.social-button:hover { background:#b8984f; border-color:#b8984f; color:#101010; }
body footer.shared-site-footer .social-unavailable { cursor:default; }
body footer.shared-site-footer .sns-links .social-unavailable { color:#aaa; border-color:#494949; background:#111; }
body footer.shared-site-footer .footer-contact { margin:0; padding:24px 0; }
body footer.shared-site-footer .contact-link { margin:0; color:#f4f4f4; text-decoration:none; font:400 15px/1.6 "Yu Gothic",Meiryo,sans-serif; }
body footer.shared-site-footer .copyright { font-size:12px; color:#999; margin:0; }
body footer.shared-site-footer a:focus-visible { outline:2px solid #dfbf77; outline-offset:4px; }
@media(max-width:520px) { body footer.shared-site-footer .sns-links { grid-template-columns:1fr; max-width:320px; } }
/* Keep content and navigation usable when animation libraries are unavailable. */
html.motion-unavailable :is(.hero-logo-img,.hero-titles h2,.hero-titles .subtitle,.enter-btn,.gs-fade-up,.news-card,.comm-card,.nation-card,.gallery-item,.timeline-item,.join-steps .step,.join-steps .step-arrow,.about-text p,.story-text p) { opacity:1!important; transform:none!important; }
.visually-hidden { position:absolute!important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
