/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Electrolize', 'Noto Sans JP', sans-serif;
    overflow-x: hidden;
    visibility: hidden;
}

body.loaded {
    visibility: visible;
}

/* Contents page container */
.contents-page {
    min-height: 100vh;
    width: 100%;
    background-image: url('../images/background.png');
    background-repeat: repeat;
    background-size: 50px 50px;
    background-position: 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px;
    gap: 32px;
    position: relative;
    animation: backgroundFlow 10s linear infinite;
}

@keyframes backgroundFlow {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 50px 50px;
    }
}

/* Head section */
.head {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    max-width: 700px;
    padding-bottom: 14px;
    padding-right: 0;
    opacity: 0;
    animation: fadeIn 1s ease-out 0.2s forwards;
}

/* Menu button */
.menu-button {
    background: transparent;
    border: none;
    padding: 0;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: -14px;
    transition: transform 0.3s ease;
    z-index: 10;
}

.menu-button:hover {
    transform: scale(1.1);
}

.menu-button:active {
    transform: scale(0.95);
}

.menu-icon {
    width: 32px;
    height: 32px;
}

/* Header */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 23px;
    width: 100%;
    margin-bottom: -9px;
}

/* Page title */
.page-title {
    font-family: 'Electrolize', sans-serif;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 10.08px;
    text-align: center;
    color: white;
    line-height: 1.261;
    -webkit-text-stroke: 5px black;
    text-stroke: 5px black;
    paint-order: stroke fill;
}

/* Search bar */
.search-bar {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 700px;
    height: 36px;
    background-color: #f4f4f4;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0 14px;
    gap: 8px;
}

.search-icon {
    flex-shrink: 0;
    color: #999;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Roboto', 'Noto Sans JP', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: black;
    background: transparent;
    min-width: 0;
}

.search-input::placeholder {
    color: #aaa;
    font-weight: 400;
}

.search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.search-clear:hover {
    color: black;
}

.search-clear.visible {
    display: flex;
}

/* Filter buttons */
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 700px;
}

.filter-btn {
    background-color: white;
    border: 1px solid black;
    border-radius: 39px;
    padding: 4px 20px;
    height: 24px;
    font-family: 'Roboto', 'Noto Sans JP', 'Noto Sans Symbols 2', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: black;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 1.5px 1.5px 0px 0px black;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 2.5px 2.5px 0px 0px black;
}

.filter-btn:active {
    transform: translateY(0);
    box-shadow: 1px 1px 0px 0px black;
}

.filter-btn.active {
    background-color: #7fff00;
    transform: translateY(1px);
    box-shadow: 0.5px 0.5px 0px 0px black;
}

/* Contents list */
.contents-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    max-width: 700px;
    opacity: 0;
    animation: fadeIn 1s ease-out 0.4s forwards;
}

/* Scene card */
.scene-card {
    background-color: white;
    border: 2px solid black;
    border-radius: 13px;
    box-shadow: 3px 3px 0px 0px black;
    padding: 10px 12px;
    width: 100%;
    min-height: 126px;
    display: flex;
    align-items: center;
    gap: 20px;
    overflow: visible;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(40px) scale(0.95);
}

.scene-card.animate-in {
    animation: cardSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Staggered animation for first 20 cards, rest appear at same time */
.scene-card:nth-child(n+1):nth-child(-n+20).animate-in {
    animation-delay: calc(0.5s + (var(--card-index, 0) * 0.05s));
}

.scene-card:nth-child(1).animate-in { --card-index: 0; }
.scene-card:nth-child(2).animate-in { --card-index: 1; }
.scene-card:nth-child(3).animate-in { --card-index: 2; }
.scene-card:nth-child(4).animate-in { --card-index: 3; }
.scene-card:nth-child(5).animate-in { --card-index: 4; }
.scene-card:nth-child(6).animate-in { --card-index: 5; }
.scene-card:nth-child(7).animate-in { --card-index: 6; }
.scene-card:nth-child(8).animate-in { --card-index: 7; }
.scene-card:nth-child(9).animate-in { --card-index: 8; }
.scene-card:nth-child(10).animate-in { --card-index: 9; }
.scene-card:nth-child(11).animate-in { --card-index: 10; }
.scene-card:nth-child(12).animate-in { --card-index: 11; }
.scene-card:nth-child(13).animate-in { --card-index: 12; }
.scene-card:nth-child(14).animate-in { --card-index: 13; }
.scene-card:nth-child(15).animate-in { --card-index: 14; }
.scene-card:nth-child(16).animate-in { --card-index: 15; }
.scene-card:nth-child(17).animate-in { --card-index: 16; }
.scene-card:nth-child(18).animate-in { --card-index: 17; }
.scene-card:nth-child(19).animate-in { --card-index: 18; }
.scene-card:nth-child(20).animate-in { --card-index: 19; }

/* Cards 21+ appear at the same time */
.scene-card:nth-child(n+21).animate-in {
    animation-delay: 1.5s;
}

.scene-card:hover {
    transform: translateY(-4px);
    box-shadow: 5px 5px 0px 0px black;
}

.scene-card:active {
    transform: translateY(0);
    box-shadow: 2px 2px 0px 0px black;
}

/* Scene image */
.scene-image {
    background-color: #f4f4f4;
    border-radius: 4px;
    padding: 2px;
    width: 105px;
    height: 105px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scene-image img {
    width: 100px;
    height: 100px;
    object-fit: cover;
}

/* Scene data */
.scene-data {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 100px;
    flex: 1;
    min-width: 0;
    overflow: visible;
}

/* Metadata */
.metadata {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-tag,
.level-tag {
    background-color: black;
    color: white;
    font-family: 'Roboto', 'Noto Sans JP', 'Noto Sans Symbols 2', sans-serif;
    font-weight: 600;
    font-size: 10px;
    padding: 1px 5px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

/* Scene number */
.scene-number {
    font-family: 'Electrolize', sans-serif;
    font-size: 30px;
    font-weight: 700;
    color: white;
    line-height: 1;
    -webkit-text-stroke: 4px black;
    text-stroke: 4px black;
    paint-order: stroke fill;
}

/* Scene location */
.scene-location {
    font-family: 'Roboto', 'Noto Sans JP', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: black;
    line-height: 0.8;
}

/* Scene title */
.scene-title {
    font-family: 'Roboto', 'Noto Sans JP', sans-serif;
    font-weight: 600;
    font-size: 20px;
    color: black;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Keyframe animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes cardSlideIn {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    50% {
        opacity: 0.8;
        transform: translateY(-3px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Menu overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(233, 231, 231, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    max-width: 700px;
    height: 100%;
    position: relative;
}

/* Close button */
.close-button {
    background: transparent;
    border: none;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    padding: 0;
    transition: transform 0.3s ease;
}

.close-button:hover {
    transform: rotate(90deg) scale(1.1);
}

.close-button:active {
    transform: rotate(90deg) scale(0.95);
}

.close-icon {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-line {
    position: absolute;
    width: 3px;
    height: 30px;
    background-color: black;
    border-radius: 1.5px;
}

.close-line-1 {
    transform: rotate(45deg);
}

.close-line-2 {
    transform: rotate(135deg);
}

/* Menu navigation */
.menu-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 41px;
    width: 100%;
    flex: 1;
    padding-bottom: 56px;
}

.menu-link {
    font-family: 'Electrolize', sans-serif;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 10.08px;
    text-align: center;
    color: white;
    line-height: 1.261;
    -webkit-text-stroke: 6px black;
    text-stroke: 6px black;
    paint-order: stroke fill;
    text-decoration: none;
    width: 100%;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

.menu-overlay.active .menu-link {
    animation: menuLinkSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.menu-overlay.active .menu-link:nth-child(1) {
    animation-delay: 0.1s;
}

.menu-overlay.active .menu-link:nth-child(2) {
    animation-delay: 0.2s;
}

.menu-overlay.active .menu-link:nth-child(3) {
    animation-delay: 0.3s;
}

.menu-overlay.active .menu-link:nth-child(4) {
    animation-delay: 0.4s;
}

.menu-link:hover {
    transform: scale(1.05);
    text-shadow: 0 0 20px rgba(127, 255, 0, 0.5);
}

.menu-link:active {
    transform: scale(0.95);
}

@keyframes menuLinkSlideIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .contents-page {
        padding: 24px 12px;
        gap: 24px;
    }

    .head {
        padding-right: 8px;
    }

    .page-title {
        font-size: 32px;
        letter-spacing: 8px;
        -webkit-text-stroke: 5px black;
        text-stroke: 5px black;
    }

    .filter-buttons {
        max-width: 100%;
    }

    .scene-card {
        height: auto;
        min-height: 126px;
        max-height: none;
    }

    .scene-data {
        width: auto;
        flex: 1;
    }
}

@media (max-width: 480px) {
    .head {
        padding-right: 12px;
    }

    .page-title {
        font-size: 28px;
        letter-spacing: 6px;
        -webkit-text-stroke: 4px black;
        text-stroke: 4px black;
    }

    .filter-btn {
        font-size: 12px;
        padding: 3px 16px;
        height: 22px;
    }

    .scene-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px;
        gap: 12px;
    }

    .scene-image {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .scene-image img {
        width: 100%;
        height: 100%;
    }

    .scene-data {
        width: 100%;
        height: auto;
    }

    .scene-number {
        font-size: 26px;
    }

    .scene-title {
        font-size: 18px;
    }

    /* Menu overlay responsive */
    .menu-content {
        gap: 150px;
    }

    .menu-link {
        font-size: 32px;
        letter-spacing: 8px;
        -webkit-text-stroke: 5px black;
        text-stroke: 5px black;
    }

    .close-button {
        width: 44px;
        height: 44px;
    }

    .close-line {
        width: 2.5px;
        height: 26px;
    }

    .menu-button {
        width: 28px;
        height: 28px;
    }

    .menu-icon {
        width: 28px;
        height: 28px;
    }
}

/* TOP Button */
.top-button {
    position: fixed;
    bottom: 24px;
    right: 4px;
    width: 64px;
    height: 64px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 50;
    padding: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.top-button.visible {
    opacity: 1;
    pointer-events: auto;
}

.top-button:hover {
    transform: scale(1.1);
}

.top-button:active {
    transform: scale(0.95);
}

.top-button-icon {
    width: 100%;
    height: 100%;
    display: block;
}

/* Tablet and desktop - align with content max-width */
@media (min-width: 768px) {
    .top-button {
        right: calc(50% - 350px + 4px);
    }
}
