@import url('grid.css');

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

:root {
    --color-indigo: #2B2E4A;
    --color-matcha: #849974;
    --color-washi: #F9F8F2;
    /* Warmer, creamier white */
    --color-vermillon: #E84545;
    --color-text-dark: #333;
    --color-text-light: #fff;
    --font-heading: 'Zen Maru Gothic', sans-serif;
    --font-body: 'Noto Sans JP', sans-serif;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--color-washi);
    /* Layered background: Texture only (gradient removed for dynamic change) */
    background-image:
        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.6' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
    color: var(--color-text-dark);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    align-items: center;
    transition: background-color 20s linear, color 20s linear;
}

/* Dark Mode Overrides for High Contrast */
body.dark-mode {
    color: var(--color-text-light);
}

body.dark-mode #appTitle,
body.dark-mode .zen-font,
body.dark-mode .about-section h2,
body.dark-mode .lang-switch button {
    color: var(--color-text-light);
}

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

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

body.dark-mode .secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .about-section {
    background: rgba(0, 0, 0, 0.2);
    color: #eee;
}

header {
    text-align: center;
    padding: 3rem 1rem;
    width: 100%;
    margin-bottom: 1rem;
}

#appTitle {
    font-size: 3rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--color-indigo);
}

#appSubtitle {
    color: #666;
    margin-top: 0.5rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

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

.lang-switch {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.lang-switch button {
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
    color: var(--color-indigo);
}

main {
    width: 100%;
    max-width: 1200px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    /* Remove gap on main to handle spacing via margins if needed, or keep it */
    gap: 2rem;
    align-items: center;
}

/* Constrain the functional app parts to 800px so they don't stretch ugly */
.controls {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
}

.char-grid-section,
.preview-area {
    width: 100%;
    max-width: 800px;
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

/* New Controls Layout */
.control-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.style-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.helper-text {
    font-size: 0.85rem;
    color: #888;
    margin-top: -0.5rem;
}

/* Disabled Palette State */
.palette {
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
    justify-content: center;
    transition: opacity 0.3s, filter 0.3s;
    max-width: 100%;
}

.palette.disabled {
    opacity: 0.5;
    /* Allow clicking to re-enable manual mode */
    cursor: pointer;
    filter: grayscale(0.8);
}

/* Toggle Button Style */
.mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-indigo);
    background: #fff;
    border: 2px solid var(--color-indigo);
    border-radius: 3rem;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: all 0.2s ease;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
}

.mode-btn.active {
    background: var(--color-indigo);
    color: #fff;
    box-shadow: 0 4px 15px rgba(43, 46, 74, 0.3);
}

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

.contact-link {
    margin-top: 1rem;
}

.contact-link a {
    color: var(--color-indigo);
    text-decoration: underline;
}

select {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 2rem;
    background: #fff;
    font-family: var(--font-body);
    min-width: 160px;
    appearance: none;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.color-swatch {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, border-color 0.2s;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: var(--color-indigo);
    transform: scale(1.1);
}

.preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    background: #fff;
    /* fallback */
    width: 320px;
    /* default preview width */
    transition: box-shadow 0.3s;
}

.canvas-actions {
    display: flex;
    gap: 1.5rem;
}

button.primary-btn,
button.secondary-btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 3rem;
    font-size: 1.1rem;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: transform 0.1s, box-shadow 0.2s;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.primary-btn {
    background-color: var(--color-indigo);
    color: #fff;
    box-shadow: 0 4px 15px rgba(43, 46, 74, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(43, 46, 74, 0.4);
    background-color: #353857;
}

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


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

/* Specific highlight for Download All to make it pop */
#btnDownloadAll {
    background-color: var(--color-vermillon);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px rgba(232, 69, 69, 0.4);
    font-weight: 700;
}

#btnDownloadAll:hover {
    background-color: #d63d3d;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(232, 69, 69, 0.5);
}

.about-section {
    width: 100%;
    max-width: 100%;
    text-align: center;
    line-height: 1.8;
    color: #555;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
}

.about-section h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--color-indigo);
}

footer {
    width: 100%;
    text-align: center;
    padding: 2rem;
    color: #888;
    font-size: 0.8rem;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.feedback-card {
    background: #fff;
    padding: 1.5rem 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    max-width: 400px;
    width: 90%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.feedback-card h4 {
    margin: 0 0 0.5rem 0;
    color: var(--color-indigo);
    font-size: 1.1rem;
    font-family: var(--font-heading);
}

.feedback-card p {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: #666;
}

.button-link {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: var(--color-indigo);
    color: #fff;
    text-decoration: none;
    border-radius: 2rem;
    font-weight: 500;
    font-size: 0.95rem;
    transition: transform 0.2s, background-color 0.2s;
}

.button-link:hover {
    transform: translateY(-2px);
    background: #353857;
}

.creator-credit {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-indigo);
    font-size: 0.9rem;
    margin: -1rem 0 0 0;
    /* Pull it closer to the feedback card or description */
}

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

.creator-credit a:hover {
    border-bottom-style: solid;
}

.hidden {
    display: none;
}

/* Guide Page Styles */
.guide-content {
    text-align: left;
    max-width: 700px;
}

.device-guide {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    border: 2px solid transparent;
}

.device-guide h3 {
    margin-top: 0;
    color: var(--color-indigo);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.device-guide ol {
    padding-left: 1.2rem;
    margin-bottom: 0;
}

.device-guide li {
    margin-bottom: 0.5rem;
}

.usage-guide {
    text-align: left;
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
}

.usage-guide h3 {
    margin-top: 0;
    color: var(--color-indigo);
}

/* Align lists to the left in the about/guide section */
.about-section ul,
.platform-guide ul {
    text-align: left;
    margin-left: 1rem;
}

.about-section ol,
.platform-guide ol {
    text-align: left;
    margin-left: 1rem;
}

/* Platform Guide Accordion */
.platform-title {
    text-align: left;
    margin-top: 2rem;
    color: var(--color-indigo);
    border-bottom: 2px solid rgba(43, 46, 74, 0.1);
    padding-bottom: 0.5rem;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.platform-title:hover {
    color: #555;
    border-bottom-color: rgba(43, 46, 74, 0.3);
}

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

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

.platform-guide {
    text-align: left;
    display: none;
    /* Hidden by default */
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* SEO Toggle Button Styling */
.seo-toggle-btn {
    background: transparent;
    border: 1px solid var(--color-indigo);
    color: var(--color-indigo);
    padding: 0.5rem 1.2rem;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--font-heading);
    font-weight: 700;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.seo-toggle-btn:hover {
    background: rgba(43, 46, 74, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.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%);
}