/**
 * あにまね！ カスタムスタイル
 * meta.html から抽出したプロジェクト固有のスタイル
 */

/* ======================================================================
   1. BASE STYLES
   ====================================================================== */
body {
    font-family: 'Zen Kaku Gothic New', 'Inter', 'Noto Sans JP', sans-serif;
    letter-spacing: 0.03em;
    line-height: 1.7;
}

h1,
h2,
h3,
.font-mincho {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 700;
    /* ゴシック体でのプレミアム感を出すために、文字間を少し広めに設定 */
    letter-spacing: 0.08em;
}

/* ======================================================================
   2. PREMIUM BACKGROUND (Washi Paper Style)
   ====================================================================== */
.premium-bg {
    position: fixed;
    inset: 0;
    z-index: -10;
    overflow: hidden;
    background-color: #fbfaf5;
    background-image: url('../static/bg-light.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    /* 生成り - 和紙の温かみ */
}

.dark .premium-bg {
    background-color: #1a1a1a;
    background-image: url('../static/bg-dark.png');
    /* 深い墨色 */
}

/* Washi Paper Texture Overlay (Subtle SVG Noise) */
.premium-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.08;
    /* 画像をメインにするためSVGノイズはさらに薄く */
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='washi'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.02' numOctaves='5' stitchTiles='stitch' result='noise'/%3E%3CfeDiffuseLighting in='noise' lighting-color='%23fff' surfaceScale='1.5'%3E%3CfeDistantLight azimuth='45' elevation='60'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23washi)'/%3E%3C/svg%3E");
    background-size: 400px 400px;
}

.dark .premium-bg::before {
    opacity: 0.03;
}

/* Background Orbs */
/* Background Orbs removed for Static Washi Design */

/* ======================================================================
   3. LOADING & SKELETON
   ====================================================================== */
.lazy-image {
    transition: opacity 0.3s ease-in-out;
}

.skeleton-shimmer {
    position: relative;
    overflow: hidden;
}

.skeleton-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: shimmer 1.5s infinite;
}

.dark .skeleton-shimmer::before {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* Nebula Fog (Kasumi) Effect */
.nebula-fog {
    position: relative;
    overflow: hidden;
    background: #f1f5f9;
}

.dark .nebula-fog {
    background: #1e293b;
}

.nebula-fog::after {
    content: '';
    position: absolute;
    inset: -50%;
    background:
        radial-gradient(circle at 30% 30%, rgba(233, 83, 69, 0.15), transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(56, 161, 219, 0.15), transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(244, 114, 182, 0.1), transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(252, 211, 77, 0.1), transparent 50%);
    filter: blur(40px);
    animation: nebula-drift 8s ease-in-out infinite alternate;
    opacity: 0.6;
}

.dark .nebula-fog::after {
    opacity: 0.3;
}

@keyframes nebula-drift {
    0% {
        transform: translate(-5%, -5%) rotate(0deg) scale(1);
    }
    50% {
        transform: translate(5%, 5%) rotate(5deg) scale(1.1);
    }
    100% {
        transform: translate(-2%, 8%) rotate(-3deg) scale(1.05);
    }
}

/* ======================================================================
   4. IMAGE FALLBACK
   ====================================================================== */
.image-error-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #f1f5f9;
    color: #94a3b8;
}

.dark .image-error-fallback {
    background-color: #1e293b;
    color: #475569;
}

.no-image-text {
    font-family: 'Mochiy Pop One', sans-serif;
    font-size: 0.75rem;
    margin-top: 0.5rem;
    letter-spacing: 0.1em;
    opacity: 0.8;
    font-weight: bold;
}

/* ======================================================================
   5. GLASSMORPHISM
   ====================================================================== */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glass {
    background: rgba(15, 23, 42, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ======================================================================
   6. FOCUS STATES
   ====================================================================== */
.focus-ring:focus {
    outline: none;
    box-shadow:
        0 0 0 2px rgb(15 23 42),
        0 0 0 4px rgb(248 250 252);
}

.dark .focus-ring:focus {
    box-shadow:
        0 0 0 2px rgb(248 250 252),
        0 0 0 4px rgb(15 23 42);
}

input:focus,
select:focus,
button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgb(236 72 153 / 0.5);
}

/* ======================================================================
   7. HEADER & NAVIGATION
   ====================================================================== */
.header-premium {
    transition: all 0.3s ease;
}

.header-premium.scrolled {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.1);
}

/* Segmented Control */
.segmented-control {
    position: relative;
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: 14px;
    transition: background 0.3s ease;
}

.dark .segmented-control {
    background: rgba(255, 255, 255, 0.05);
}

.segmented-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    height: calc(100% - 8px);
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.15);
    z-index: 1;
}

.dark .segmented-slider {
    background: #e91e63;
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
}

/* フィルタ表示モード専用の色（露草色） */
.dark #filter-mode-slider {
    background: #38a1db;
    box-shadow: 0 4px 15px rgba(56, 161, 219, 0.3);
}

.segmented-item {
    position: relative;
    z-index: 2;
    flex: 1;
}

/* ======================================================================
   8. LOGO
   ====================================================================== */
.logo-container {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.05));
}

.logo-animane {
    font-size: 2.5rem;
    line-height: 1;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.02em;
    letter-spacing: -0.02em;
}

@media (max-width: 640px) {
    .logo-animane {
        font-size: 1.8rem;
    }
}

.logo-animane span {
    display: block;
    position: relative;
    paint-order: stroke fill;
    -webkit-text-stroke: 8px #fffbeb;
    margin-right: -0.12em;
}

.dark .logo-animane span {
    -webkit-text-stroke: 8px #374151;
}

.char-1 {
    color: #e95345;
    transform: rotate(-5deg) translateY(-3px);
    z-index: 5;
    margin-right: 0.05em !important;
}

.char-2 {
    color: #fcd34d;
    transform: rotate(3deg) translateY(-4px);
    z-index: 4;
}

.char-3 {
    color: #f472b6;
    transform: rotate(-4deg) translateY(-1px);
    z-index: 3;
}

.char-4 {
    color: #fb7185;
    transform: rotate(4deg) translateY(-3px);
    z-index: 2;
}

.char-5 {
    color: #f59e0b;
    transform: scale(1.15) rotate(8deg) translateY(-1px);
    z-index: 6 !important;
    margin-left: -0.1em !important;
}

.font-mochiy {
    font-family: 'Mochiy Pop One', sans-serif;
}

/* ======================================================================
   9. SCROLLBAR
   ====================================================================== */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-thin::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.scrollbar-thin::-webkit-scrollbar-track {
    background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5);
    border-radius: 2px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.8);
}

.dark .scrollbar-thin::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.5);
}

.dark .scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: rgba(75, 85, 99, 0.8);
}

/* ======================================================================
   10. SEASON TITLE POPUP
   ====================================================================== */
.season-title-anim {
    position: relative;
}

.anim-popup {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%) translateY(5px) scale(0.8);
    color: #1f2937;
    font-family: 'Mochiy Pop One', sans-serif;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 50;
}

.dark .anim-popup {
    color: #f3f4f6;
}

.season-title-anim:hover .anim-popup {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px) scale(1.1);
}

/* ======================================================================
   11. ANIME CARD
   ====================================================================== */
.anime-card {
    opacity: 0;
    transform: translateY(24px);
    transition: all 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, opacity;
    box-shadow: 0 8px 30px rgb(0 0 0 / 0.04);
    content-visibility: auto;
    contain-intrinsic-size: auto 320px;
}

.dark .anime-card {
    box-shadow: 0 8px 30px rgb(0 0 0 / 0.2);
}

.anime-card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.anime-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow:
        0 20px 50px -10px rgba(0, 0, 0, 0.12),
        0 12px 24px -12px rgba(0, 0, 0, 0.1);
}

.dark .anime-card:hover {
    box-shadow:
        0 20px 50px -10px rgba(0, 0, 0, 0.4),
        0 12px 24px -12px rgba(0, 0, 0, 0.3);
}

.shadow-soft {
    box-shadow: 0 8px 30px rgb(0 0 0 / 0.04);
}

.dark .shadow-soft {
    box-shadow: 0 8px 30px rgb(0 0 0 / 0.2);
}

/* ======================================================================
   12. ANIME GRID LAYOUTS
   ====================================================================== */
.anime-grid {
    display: grid;
    gap: 1rem;
    transition: all 0.3s ease;
}

@media (min-width: 1280px) {
    .container {
        max-width: 95%;
    }
}

/* Standard Layout */
body[data-layout='standard'] .anime-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 640px) {
    body[data-layout='standard'] .anime-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    body[data-layout='standard'] .anime-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    body[data-layout='standard'] .anime-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (min-width: 1536px) {
    body[data-layout='standard'] .anime-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }
}

@media (min-width: 1920px) {
    body[data-layout='standard'] .anime-grid {
        grid-template-columns: repeat(10, minmax(0, 1fr));
    }
}

@media (min-width: 2560px) {
    body[data-layout='standard'] .anime-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
}

/* Detailed Layout */
body[data-layout='detailed'] .anime-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1.5rem;
}

@media (min-width: 768px) {
    body[data-layout='detailed'] .anime-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    body[data-layout='detailed'] .anime-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1536px) {
    body[data-layout='detailed'] .anime-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Standard Layout Card Adjustments */
body[data-layout='standard'] .anime-card .channel-text {
    display: none !important;
}

body[data-layout='standard'] .anime-card .channel-icon {
    margin-right: 0 !important;
}

body[data-layout='standard'] .today-badge {
    font-size: 8px !important;
    padding: 2px 4px !important;
    top: 6px !important;
    left: 6px !important;
}

/* List Layout */
body[data-layout='list'] .anime-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

body[data-layout='list'] .anime-card {
    flex-direction: row;
    height: auto;
    min-height: 160px;
}

body[data-layout='list'] .card-image-container {
    width: 260px;
    height: auto;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    margin: 12px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-right: 1px solid rgba(229, 231, 235, 0.5);
}

.dark body[data-layout='list'] .card-image-container {
    border-right: 1px solid rgba(75, 85, 99, 0.5);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 2px 4px -1px rgba(0, 0, 0, 0.18);
}

@media (max-width: 640px) {
    body[data-layout='list'] .card-image-container {
        width: 140px;
        margin: 8px;
        border-radius: 8px;
    }

    body[data-layout='list'] .anime-card h3 {
        font-size: 0.875rem;
    }
}

/* ======================================================================
   13. CARD IMAGE HOVER EFFECT
   ====================================================================== */
.card-image-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: translateX(-300%) skewX(-25deg);
    transition: transform 0.5s ease-out;
    pointer-events: none;
    will-change: transform;
}

.anime-card:hover .card-image-container::after {
    transform: translateX(300%) skewX(-25deg);
}

/* ======================================================================
   14. MOBILE PERFORMANCE OPTIMIZATIONS
   ====================================================================== */
@media (max-width: 768px), (hover: none) {
    .card-image-container::after {
        display: none;
    }

    .lazy-image {
        transition: none !important;
        transform: none !important;
    }

    .anime-card:hover .lazy-image {
        transform: none !important;
    }

    .anime-card {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        will-change: auto !important;
    }

    .anime-card:hover {
        transform: none !important;
        box-shadow: 0 8px 30px rgb(0 0 0 / 0.04) !important;
    }

    .anime-card.is-visible {
        transform: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .anime-card {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .card-image-container::after {
        display: none;
    }
}

noscript .anime-card {
    opacity: 1 !important;
    transform: none !important;
}

/* ======================================================================
   15. FILTER BADGE CHECKED STATE
   ====================================================================== */
/* お気に入りフィルターがONの時、バッジを白文字に */
#favorites-toggle-toolbar:has(input:checked) #count-favorites-badge {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

/* 未配信フィルターがONの時、バッジを白文字に */
#show-unavailable-toggle-toolbar:has(input:checked) #count-unavailable-badge {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}
