/* =========================================================================
   1. VARIABLES & BASE
   ========================================================================= */
:root {
    --bg-color: #fff;
    --text-color: #111;
    --accent-color: #333;
    --border-color: #e0e0e0;
    --font-serif: 'GFS Didot', serif;
    --font-sans: 'Inter', 'Noto Sans JP', sans-serif;
    --font-type: 'Courier Prime', monospace;
    --max-width: 1200px;
    --transition-speed: 0.3s;
}

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

html,
body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    font-size: 16px;
    background-image: url('images/bg.jpg');
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    line-height: 1.8;
    letter-spacing: 0.04em;
    -webkit-font-smoothing: antialiased;
}

ul {
    list-style: none;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Helpers */
.highlight {
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
    letter-spacing: 0.08em;
}

.separator-v {
    width: 0px;
    height: 40vh;
    background: var(--border-color);
    margin: auto 0;
    flex-shrink: 0;
}


/* =========================================================================
   2. TYPOGRAPHY
   ========================================================================= */
h1,
h2,
h3 {
    font-family: var(--font-serif);
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--text-color);
}

.font-serif {
    font-family: var(--font-serif);
}

.font-sans {
    font-family: var(--font-sans);
}

.font-type {
    font-family: var(--font-type);
}

/* Hero Typography */
.hero-title {
    font-size: clamp(2.5rem, 5vw, 8rem);
    margin-bottom: 3rem;
    line-height: 1.1;
}

.hero-subtitle {
    font-size: clamp(1.0rem, 2.5vw, 1.5rem);
    line-height: 1.5;
    margin-bottom: 0.1rem;
    font-weight: 400;
    color: #444;
}

.hero-text {
    font-size: clamp(0.9rem, 1.8vw, .8rem);
    line-height: 1.8;
    margin: 2rem auto 0.2rem;
    font-weight: 400;
    color: #444;
}

/* Section Typography */
.section-title {
    font-size: clamp(1.5rem, 3.5vw, 2.2rem);
    margin-bottom: 30px;
    border-bottom: 1px solid transparent;
    display: inline-block;
}

.section-body p {
    font-size: clamp(0.9rem, 1.8vw, .8rem);
    margin-bottom: 1.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* List Typography */
.data-list,
.policy-list {
    font-family: 'Noto Sans JP', monospace;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    border-left: 1px solid var(--border-color);
    padding-left: 1.5rem;
    text-align: left;
    display: inline-block;
}

.data-list li,
.policy-list li {
    margin-bottom: 0.5rem;
}


/* =========================================================================
   3. LAYOUT & COMPONENTS
   ========================================================================= */
/* Horizontal Wrapper */
#horizontal-wrapper {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: fit-content;
    overflow: hidden;
    will-change: transform;
}

.section {
    width: 100vw;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 40px;
    position: relative;
    opacity: 1;
}

.content-wrapper {
    width: 100%;
    max-width: var(--max-width);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 100vh;
    overflow-y: visible;
}

/* Header Nav */
#header-nav {
    position: fixed;
    top: 20px;
    right: 30px;
    z-index: 100;
    mix-blend-mode: difference;
}

#header-nav ul {
    display: flex;
    gap: 20px;
}

#header-nav a {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    opacity: 0.7;
    transition: opacity 0.3s;
}

#header-nav a:hover {
    opacity: 1;
}

/* Hamburger Menu Toggle (Default Hidden) */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 30px;
    position: relative;
    z-index: 102;
    /* Above nav list */
    padding: 0;
}

.menu-toggle .line {
    display: block;
    width: 100%;
    height: 2px;
    background-color: #fff;
    position: absolute;
    left: 0;
    transition: all 0.3s ease;
}

.menu-toggle .line1 {
    top: 10px;
}

.menu-toggle .line2 {
    bottom: 10px;
}

/* Menu Open State (Animation) */
body.menu-open .menu-toggle .line1 {
    transform: rotate(45deg);
    top: 14px;
}

body.menu-open .menu-toggle .line2 {
    transform: rotate(-45deg);
    bottom: 14px;
}

/* Mobile Nav Styles */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    /* Reset blend mode when menu is open so content is visible on white */
    body.menu-open #header-nav {
        mix-blend-mode: normal;
    }

    /* Change toggle lines to black when open */
    body.menu-open .menu-toggle .line {
        background-color: #333;
    }

    #header-nav ul {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(255, 255, 255, 0.98);
        /* White Layout */
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 3rem;
        padding: 0;
        margin: 0;
        z-index: 101;
        /* Below toggle */
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    #header-nav a {
        font-size: 2rem;
        font-family: var(--font-serif);
        /* Editorial feel */
        color: #333;
        font-weight: 400;
        letter-spacing: 0.1em;
        position: relative;
    }

    /* Open State */
    body.menu-open #header-nav ul {
        opacity: 1;
        visibility: visible;
    }

    body.menu-open {
        overflow: hidden;
        /* Prevent scrolling when menu is open */
    }
}

/* Bottom TOC/Nav */
#toc-bottom {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
}

#toc-list-bottom ul {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#toc-list-bottom a {
    display: block;
    width: 30px;
    height: 4px;
    background: #ddd;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    cursor: pointer;
}

#toc-list-bottom a:hover,
#toc-list-bottom a.active {
    background: #111;
    transform: scaleY(1.5);
}

#toc-list-bottom a::after {
    content: attr(data-title);
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: #111;
    color: #fff;
    padding: 0.3em 1em 0.15em;
    font-size: 0.7rem;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    font-family: var(--font-type);
    letter-spacing: 0.05em;
}

#toc-list-bottom a:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Scroll Hint */
.scroll-hint {
    position: absolute;
    bottom: 4rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0.7;
    z-index: 10;
}

.scroll-hint .text {
    font-family: var(--font-type);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    color: #333;
    font-weight: 600;
}

.scroll-hint .line {
    width: 1px;
    height: 60px;
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.scroll-hint .line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #333;
    animation: scrollUp 2s cubic-bezier(0.77, 0, 0.175, 1) infinite;
}

@keyframes scrollUp {
    0% {
        transform: translateY(100%);
    }

    100% {
        transform: translateY(-100%);
    }
}

/* Progress Bar */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: #111;
    width: 0%;
    z-index: 99999;
}

/* Fixed Copyright */
.copyright {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    font-size: 0.7rem;
    color: #333;
    z-index: 9999;
    pointer-events: none;
    font-family: var(--font-type);
}


/* =========================================================================
   4. SECTION SPECIFIC STYLES
   ========================================================================= */
/* Hero Section Specifics */
.section-hero .hero-subtitle {
    margin: 0;
    line-height: 1.05;
    letter-spacing: .02em;
}

.section-hero .hero-subtitle-2 {
    opacity: .85;
}

.section-hero .hero-text {
    margin-top: 1.6rem;
    max-width: 42rem;
}

/* What is Riddim */
#what-is .key {
    display: inline-block;
    font-weight: 600;
    letter-spacing: .04em;
    border-bottom: 1px solid currentColor;
    padding-bottom: .08em;
}

/* Why Wear (Matrix Numbers) */
.matrix-numbers {
    font-family: var(--font-type);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #444;
}

/* Side A B */
#side-a-b .bg-layer {
    width: 100vw;
    height: 100vh;
    text-align: right;
}

#side-a-b .bg-layer img {
    width: 50%;
}

/* Design Policy */
#design-policy .bg-layer {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

#design-policy .bg-layer img {
    box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.2);
    position: absolute;
}

#design-policy #design1 {
    width: 42vw;
    top: 20vh;
    left: -12vw;
}

#design-policy #design2 {
    width: 25vw;
    top: 10vw;
    right: 0;
}

#design-policy #design3 {
    width: 25vw;
    top: 38vw;
    right: 5vw;
}

/* Body Quality */
#body-quality .bg-layer {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

#body-quality .bg-layer img {
    box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.2);
    position: absolute;
}

#body-quality #body1 {
    width: 25vw;
    top: 10vh;
    right: 0;
}

#body-quality #body2 {
    width: 25vw;
    bottom: 5vh;
    right: 2vw;
}

/* Who Is */
#who-is .bg-layer {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

#who-is .bg-layer img {
    box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.2);
    position: absolute;
}

#who-is #who1 {
    width: 40vw;
    top: 20vh;
    right: 0;
}


/* =========================================================================
   5. ARCHIVE SYSTEM
   ========================================================================= */
#archive .section-body {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4vw;
}

.archive-list {
    width: 640px;
    position: relative;
    margin: 0 auto 0;
}

.archive-list p {
    margin: 4vh auto;
}

.archive-card {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0;
    border: 1px solid var(--border-color);
    background: #fff;
    transition: box-shadow 0.3s;
    position: absolute;
    top: 10vh;
    left: 0;
    cursor: pointer;
    overflow: hidden;
    will-change: transform;
    transform: translateZ(0);
}

.archive-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Inactive Overlay */
.archive-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.3);
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.archive-card.is-inactive::after {
    opacity: 1;
}

.archive-card figure {
    width: 50%;
    margin: 0;
    display: flex;
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

.archive-card figure img {
    width: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.archive-card figure img:first-child {
    position: relative;
    display: block;
    height: auto;
    opacity: 0;
}

.archive-card figure img:not(:first-child) {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    opacity: 0;
}

.archive-card figure img.active,
.archive-card figure img:first-child.active {
    opacity: 1;
    z-index: 10;
}

/* Card Data */
.archive-card .data {
    width: 50%;
    padding: 1.5vw 2vw;
    text-align: left;
}

.archive-card .data .card-title {
    font-weight: 700;
    text-align: center;
    color: #333;
}

.archive-card .data dl {
    text-align: left;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 1rem;
    margin-top: 1rem;
    margin-bottom: 1em;
    padding: .5em 0;
    font-size: 0.8rem;
    font-family: var(--font-type);
    line-height: 1.8;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
}

.archive-card .data dd {
    font-weight: 700;
    margin: 0;
    color: #333;
}

.archive-card .data a {
    font-family: var(--font-type);
    font-weight: 700;
    color: #333;
    text-align: left;
}

.archive-card .data a:hover {
    color: #000;
}

/* Arrows */
.card-arrow {
    text-align: left;
    margin-right: 0.5rem;
    display: inline-block;
    transition: transform 0.3s;
}

.card-arrow-link:hover .card-arrow {
    transform: translateX(2px);
}

/* Image Pagination */
.image-pagination {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: 20px;
    backdrop-filter: blur(2px);
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transition: all 0.3s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.dot.active {
    background: #fff;
    transform: scale(1.3);
}


/* =========================================================================
   6. CTA STYLES
   ========================================================================= */
/* CTA */
.cta-container {
    margin-top: 2rem;
}

.btn-cta {
    padding: 0.8rem 2.5rem;
    border: 1px solid #111;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    transition: 0.3s;
}

.btn-cta:hover {
    background: #111;
    color: #fff;
}

/* Riddim List */
.riddim-list {
    list-style: none;
    padding: 0;
    margin-top: 3rem;
    text-align: left;
    display: inline-block;
}

.riddim-list li {
    margin-bottom: 0.8rem;
}

.riddim-link {
    font-family: var(--font-type);
    font-weight: 700;
    color: #333;
    text-decoration: none;
    display: inline-block;
    font-size: 0.85rem;
    transition: color 0.3s;
}

.riddim-link:hover {
    color: #000;
}

/* Mini Footer */
#footer-mini {
    margin-top: 3rem;
    padding-top: 2rem;
    width: 100%;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.social-placeholder {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
}


/* =========================================================================
   7. ANIMATIONS & UTILITY
   ========================================================================= */
/* Background Layer */
.bg-layer {
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.bg-layer img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Loading Screen */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    z-index: 100000;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.sound-wave-container {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    filter: blur(2px);
}

.wave {
    position: absolute;
    border: 1px solid #666;
    border-radius: 50%;
    opacity: 0;
}

.wave1 {
    width: 30px;
    height: 30px;
    animation: vibrate 1.5s infinite cubic-bezier(0.36, 0.11, 0.89, 0.32);
}

.wave2 {
    width: 60px;
    height: 60px;
    animation: vibrate 1.5s 0.1s infinite cubic-bezier(0.36, 0.11, 0.89, 0.32);
}

.wave3 {
    width: 90px;
    height: 90px;
    animation: vibrate 1.5s 0.2s infinite cubic-bezier(0.36, 0.11, 0.89, 0.32);
}

@keyframes vibrate {
    0% {
        transform: scale(0.9);
        opacity: 0.3;
    }

    50% {
        transform: scale(1.3);
        opacity: .8;
    }

    100% {
        transform: scale(0.9);
        opacity: 0.3;
    }
}


/* =========================================================================
   8. MEDIA QUERIES
   ========================================================================= */
/* =========================================================================
   8. MEDIA QUERIES (MOBILE VERTICAL SCROLL)
   ========================================================================= */
@media (max-width: 768px) {

    /* Unwrap Horizontal Scroll */
    html,
    body {
        overflow: visible;
        /* Fix for sticky */
        overflow-x: hidden;
        /* Keep x hidden if possible, but visible is stuck-safe */
    }

    /* Force reset on body to be safe */
    body {
        position: relative;
    }

    #horizontal-wrapper {
        display: block;
        width: 100%;
        height: auto;
        overflow: visible;
        /* CRITICAL for sticky */
    }

    /* Reverting to Flex to keep ordering simple, but ensuring width/height are robust */
    .section {
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding: 5rem 1.5rem 4rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        /* Center content vertically */
        align-items: center;
        gap: 3rem;
        overflow: visible;
    }

    /* Sticky Fix: Ensure intermediate wrappers don't clip or limit height */
    #archive .section-body {
        display: block;
        /* Reset from Flex to Block for sticky context */
        width: 100%;
        overflow: visible;
    }

    /* Order: Content First */
    .content-wrapper {
        max-height: none;
        order: 1;
        width: 100%;
        flex-shrink: 0;
        z-index: 2;
        overflow: visible;
        /* CRITICAL for sticky */
        display: block;
        /* Ensure it wraps properly */
    }

    /* Order: BG Second (Below) */
    .bg-layer {
        position: relative;
        /* Reset absolute */
        order: 2;
        width: 100%;
        height: auto !important;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        z-index: 1;
        pointer-events: auto;
    }

    .bg-layer img {
        width: 100%;
        height: auto;
        max-width: 100%;
        object-fit: contain;
        margin: 0 auto;
    }

    /* Reset specific bg styles to flow naturally */
    #side-a-b .bg-layer,
    #design-policy .bg-layer,
    #body-quality .bg-layer,
    #who-is .bg-layer {
        position: relative;
        width: 100%;
        height: auto;
    }

    /* Stack images nicely */
    #design-policy .bg-layer img,
    #body-quality .bg-layer img,
    #side-a-b .bg-layer img,
    #who-is .bg-layer img {
        position: relative;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        width: 100%;
        margin-bottom: 1rem;
        box-shadow: none;
        display: block;
    }

    #design-policy #design1,
    #design-policy #design2,
    #design-policy #design3 {
        width: 100%;
    }

    #body-quality #body1,
    #body-quality #body2 {
        width: 100%;
    }

    #who-is #who1 {
        width: 100%;
    }


    /* Separator becomes horizontal divider */
    .separator-v {
        width: 80%;
        height: 0px;
        margin: 3rem auto;
    }

    /* Typography Adjustments */
    .section-hero .hero-title img {
        width: 100%;
    }

    .section-hero .hero-subtitle {
        font-size: 1.1rem;
    }

    /* Archive List: Ensure it is a valid scroll container child */
    .archive-list {
        width: 100%;
        height: auto !important;
        display: block;
        margin-top: 0;
        padding-bottom: 5vh;
        overflow: visible;
    }

    .archive-card {
        position: relative;
        /* Back to relative */
        top: auto;
        left: auto;
        transform: none;
        width: 100%;
        margin-bottom: 2rem;
        /* Normal margin */
        padding-bottom: 2rem;
        display: flex;
        flex-direction: column;
        border: 1px solid var(--border-color);
        background: #fff;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
        z-index: 1;
    }

    .archive-card:last-child {
        margin-bottom: 0;
    }

    .archive-card:hover {
        transform: none;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
        /* Keep inconsistent static shadow or remove hover effect */
    }

    .archive-card.is-inactive::after {
        display: none;
    }

    /* Archive Card Internals: Image Top, Data Bottom */
    .archive-card figure {
        width: 100%;
        order: 1;
        margin: 0;
    }

    .archive-card .data {
        width: 100%;
        order: 2;
        padding: 1.5rem;
    }

    /* Hide Desktop Nav/Scroll Elements */
    #toc-bottom,
    #progress-bar,
    .scroll-hint {
        display: none;
    }

    /* Adjust Footer */
    #footer-mini {
        padding-bottom: 4rem;
    }

    .copyright {
        position: relative;
        bottom: auto;
        left: auto;
        text-align: center;
        width: 100%;
        margin-top: 0;
        padding-bottom: 2rem;
    }
}