@import url('grid.css');

/* ==========================================
   MOJIWALL - Japanese Traditional Design
   ========================================== */

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

/* ==========================================
   JAPANESE COLOR PALETTE (Traditional Names)
   ========================================== */
:root {
    /* Primary Colors */
    --sumi: #2B2E4A;           /* 墨 - Ink black/navy */
    --beni: #C53D43;           /* 紅 - Deep red */
    --kinari: #F9F8F2;         /* 生成り - Natural cream */
    --nezumi: #787878;         /* 鼠 - Mouse gray */

    /* Accent Colors */
    --matcha: #849974;         /* 抹茶 - Green tea */
    --sakura: #FEDFE1;         /* 桜 - Cherry blossom */
    --fuji: #8B81C3;           /* 藤 - Wisteria purple */
    --asagi: #48929B;          /* 浅葱 - Light blue-green */

    /* Functional */
    --text-dark: #333;
    --text-light: #fff;
    --text-muted: #6b6b6b;
    --border-light: rgba(43, 46, 74, 0.1);
    --shadow-soft: rgba(0, 0, 0, 0.08);
    --shadow-medium: rgba(0, 0, 0, 0.12);

    /* Typography */
    --font-heading: 'Zen Maru Gothic', 'Hiragino Kaku Gothic Pro', sans-serif;
    --font-body: 'Noto Sans JP', 'Hiragino Kaku Gothic Pro', sans-serif;

    /* Spacing (based on 8px grid) */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;

    /* Borders */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* ==========================================
   BASE STYLES
   ========================================== */
body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--kinari);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 20s linear, color 20s linear;

    /* Seigaiha (wave) pattern - subtle traditional Japanese pattern */
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='50' viewBox='0 0 100 50'%3E%3Cpath fill='none' stroke='%232B2E4A' stroke-width='0.3' stroke-opacity='0.07' d='M0 25 Q25 0 50 25 T100 25 M0 50 Q25 25 50 50 T100 50 M0 0 Q25 -25 50 0 T100 0'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
}

/* ==========================================
   LAYOUT STRUCTURE
   ========================================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: var(--space-lg) var(--space-sm);
    position: relative;
}

/* Decorative line under header */
header::after {
    content: '';
    display: block;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--sumi), transparent);
    margin: var(--space-md) auto 0;
    opacity: 0.3;
}

#appTitle {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--sumi);
    margin: 0;
}

#appSubtitle {
    color: var(--text-muted);
    margin-top: var(--space-xs);
    font-weight: 300;
    font-size: 0.95rem;
    letter-spacing: 0.03em;
}

.zen-font {
    font-family: var(--font-heading);
}

/* Language Switch */
.lang-switch {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
}

.lang-switch a {
    font-size: 0.85rem;
    color: var(--sumi);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    transition: all 0.2s ease;
}

.lang-switch a:hover {
    background: var(--sumi);
    color: var(--text-light);
}

/* ==========================================
   MAIN CONTENT - TWO COLUMN LAYOUT
   ========================================== */
main {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-sm);
}

/* App Section - Preview + Controls side by side on desktop */
.app-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

@media (min-width: 900px) {
    .app-section {
        grid-template-columns: minmax(300px, 400px) 1fr;
        align-items: start;
    }
}

/* ==========================================
   PREVIEW AREA (Left side on desktop)
   ========================================== */
.preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    position: sticky;
    top: var(--space-sm);
}

/* Canvas with frame effect */
.canvas-wrapper {
    position: relative;
    padding: 12px;
    background: linear-gradient(135deg, #e8e6e0 0%, #f5f4f0 50%, #e8e6e0 100%);
    border-radius: var(--radius-md);
    box-shadow:
        0 2px 4px var(--shadow-soft),
        0 8px 24px var(--shadow-medium),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Inner shadow for depth */
.canvas-wrapper::before {
    content: '';
    position: absolute;
    inset: 12px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    pointer-events: none;
}

canvas#wallpaperCanvas {
    display: block;
    aspect-ratio: var(--preview-aspect-ratio, 9 / 16);
    width: 100%;
    max-width: 280px;
    max-height: 500px;
    border-radius: var(--radius-sm);
    background: #fafafa;
}

/* Action buttons below canvas */
.canvas-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
}

/* ==========================================
   CONTROLS AREA (Right side on desktop)
   ========================================== */
.controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Control Groups with Japanese-style section headers */
.control-group {
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--border-light);
}

.control-group-header {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-light);
}

.control-group-header h3 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--sumi);
    margin: 0;
    letter-spacing: 0.05em;
}

/* Filter items (type, level) */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: flex-start;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.filter-item label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Select dropdowns - Japanese style */
select {
    padding: 0.7rem 2rem 0.7rem 1rem;
    font-size: 0.95rem;
    font-family: var(--font-body);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232B2E4A' d='M6 8L2 4h8z'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
    appearance: none;
    cursor: pointer;
    min-width: 140px;
    transition: all 0.2s ease;
}

select:hover {
    border-color: var(--sumi);
}

select:focus {
    outline: none;
    border-color: var(--sumi);
    box-shadow: 0 0 0 3px rgba(43, 46, 74, 0.1);
}

/* ==========================================
   COLOR PALETTE
   ========================================== */
.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Random button */
.mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-heading);
    color: var(--sumi);
    background: #fff;
    border: 2px solid var(--sumi);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: var(--kinari);
    transform: translateY(-1px);
}

.mode-btn.active {
    background: var(--sumi);
    color: var(--text-light);
}

.mode-btn .icon {
    font-size: 1.1rem;
}

/* Divider */
.style-divider {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.style-divider::before,
.style-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

/* Color swatches */
.palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    justify-content: center;
    transition: opacity 0.3s, filter 0.3s;
}

.palette.disabled {
    opacity: 0.4;
    filter: grayscale(0.7);
}

.color-swatch {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px var(--shadow-soft);
    transition: all 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px var(--shadow-medium);
}

.color-swatch.active {
    border-color: var(--sumi);
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--kinari), 0 0 0 4px var(--sumi);
}

/* ==========================================
   CHARACTER GRID
   ========================================== */
.char-grid-section {
    width: 100%;
}

.char-grid-section h2 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 500;
    color: var(--sumi);
    margin: 0 0 var(--space-sm) 0;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.char-grid-section h2::before {
    content: '文';
    font-size: 0.8rem;
    opacity: 0.4;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 0.5rem;
    max-height: 220px;
    overflow-y: auto;
    padding: var(--space-sm);
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.char-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    color: var(--text-dark);
}

.char-item:hover {
    background: var(--kinari);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.char-item.active {
    background: var(--sumi);
    color: var(--text-light);
    border-color: var(--sumi);
}

/* Custom scrollbar */
.char-grid::-webkit-scrollbar {
    width: 6px;
}

.char-grid::-webkit-scrollbar-track {
    background: transparent;
}

.char-grid::-webkit-scrollbar-thumb {
    background: rgba(43, 46, 74, 0.2);
    border-radius: var(--radius-full);
}

.char-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(43, 46, 74, 0.3);
}

/* ==========================================
   BUTTONS
   ========================================== */
button.primary-btn,
button.secondary-btn {
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-heading);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}

.primary-btn {
    background: var(--sumi);
    color: var(--text-light);
    border: none;
    box-shadow: 0 2px 8px rgba(43, 46, 74, 0.25);
}

.primary-btn:hover {
    background: #3a3d5c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(43, 46, 74, 0.3);
}

.secondary-btn {
    background: transparent;
    color: var(--sumi);
    border: 1.5px solid var(--sumi);
}

.secondary-btn:hover {
    background: rgba(43, 46, 74, 0.05);
}

/* Download All - accent button */
#btnDownloadAll {
    background: var(--beni);
    color: var(--text-light);
    border: none;
    box-shadow: 0 2px 8px rgba(197, 61, 67, 0.3);
}

#btnDownloadAll:hover {
    background: #b33339;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(197, 61, 67, 0.4);
}

/* ==========================================
   ABOUT SECTION
   ========================================== */
.about-section {
    max-width: 800px;
    margin: var(--space-xl) auto;
    padding: var(--space-lg);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}

.about-section h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--sumi);
    margin: var(--space-lg) 0 var(--space-sm);
    position: relative;
    padding-left: var(--space-md);
}

.about-section h2:first-child {
    margin-top: 0;
}

/* Decorative line before h2 */
.about-section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    background: var(--beni);
    border-radius: var(--radius-full);
}

.about-section h3 {
    font-size: 1.1rem;
    color: var(--sumi);
    margin: var(--space-md) 0 var(--space-xs);
}

.about-section p {
    color: var(--text-muted);
    line-height: 1.8;
    margin: 0 0 var(--space-sm);
}

.about-section ul,
.about-section ol {
    color: var(--text-muted);
    line-height: 1.8;
    padding-left: var(--space-md);
}

.about-section li {
    margin-bottom: var(--space-xs);
}

/* Platform accordions */
.platform-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    margin-top: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    color: var(--sumi);
    font-weight: 500;
    transition: color 0.2s;
}

.platform-title:hover {
    color: var(--beni);
}

.platform-title::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: 300;
    transition: transform 0.3s;
}

.platform-title.active::after {
    transform: rotate(45deg);
}

.platform-guide {
    display: none;
    opacity: 0;
    padding: var(--space-sm) 0;
}

.platform-guide.active {
    display: block;
    opacity: 1;
    animation: fadeIn 0.3s ease;
}

.platform-guide h4 {
    font-size: 0.95rem;
    color: var(--sumi);
    margin: var(--space-sm) 0 var(--space-xs);
}

.platform-guide ul {
    margin: 0;
    padding-left: var(--space-md);
}

/* ==========================================
   FOOTER
   ========================================== */
footer {
    text-align: center;
    padding: var(--space-lg);
    margin-top: auto;
    border-top: 1px solid var(--border-light);
}

footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0 0 var(--space-sm);
}

.creator-credit {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--sumi);
    font-size: 0.85rem;
}

.creator-credit a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
}

.creator-credit a:hover {
    color: var(--beni);
    border-bottom-style: solid;
}

.feedback-card {
    display: inline-block;
    background: #fff;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    margin: var(--space-md) 0;
    max-width: 350px;
}

.feedback-card h4 {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--sumi);
    margin: 0 0 var(--space-xs);
}

.feedback-card p {
    font-size: 0.85rem;
    margin: 0 0 var(--space-sm);
}

.button-link {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: var(--sumi);
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.button-link:hover {
    background: #3a3d5c;
    transform: translateY(-1px);
}

/* ==========================================
   SEO SECTION
   ========================================== */
.seo-char-list-container {
    max-width: 800px;
    margin: 0 auto var(--space-lg);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-md);
}

.seo-char-list-container h3 {
    color: var(--sumi);
    margin: 0 0 var(--space-sm);
    font-size: 1rem;
}

.seo-group h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: var(--space-sm) 0 var(--space-xs);
}

.seo-content {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.seo-content.collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.seo-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-family: var(--font-heading);
    cursor: pointer;
    margin-top: var(--space-xs);
    transition: all 0.2s ease;
}

.seo-toggle-btn:hover {
    border-color: var(--sumi);
    color: var(--sumi);
}

/* ==========================================
   LANGUAGE BANNER
   ========================================== */
#language-banner {
    background: var(--sumi);
    color: var(--text-light);
    display: none;
    position: relative;
}

#language-banner.visible {
    display: block;
    animation: slideDown 0.3s ease;
}

.banner-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.7rem var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
}

.banner-content a {
    color: var(--text-light);
    font-weight: 600;
}

.banner-close {
    position: absolute;
    right: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.3rem;
}

.banner-close:hover {
    color: var(--text-light);
}

/* ==========================================
   UTILITIES
   ========================================== */
.hidden {
    display: none !important;
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

@keyframes toastSlideIn {
    from { transform: translateX(-50%) translateY(100%); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(100%); opacity: 0; }
}

/* ==========================================
   DARK MODE
   ========================================== */
body.dark-mode {
    color: var(--text-light);
}

body.dark-mode #appTitle,
body.dark-mode .zen-font,
body.dark-mode .about-section h2,
body.dark-mode .control-group-header h3 {
    color: var(--text-light);
}

body.dark-mode .control-group,
body.dark-mode .about-section,
body.dark-mode .char-grid {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .primary-btn {
    background: #fff;
    color: var(--sumi);
}

body.dark-mode .secondary-btn {
    border-color: #fff;
    color: #fff;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 600px) {
    :root {
        --space-lg: 2rem;
        --space-xl: 3rem;
    }

    .canvas-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .canvas-actions button {
        width: 100%;
    }

    .filter-row {
        flex-direction: column;
        width: 100%;
    }

    .filter-item {
        width: 100%;
    }

    select {
        width: 100%;
    }

    .about-section {
        padding: var(--space-md);
    }
}
