/* SutonnyMJ (Bijoy) font — uses a locally installed copy if the visitor has
   one, otherwise a file you can drop into assets/fonts/. Falls back silently. */
@font-face {
    font-family: "SutonnyMJ";
    src: local("SutonnyMJ"), local("Sutonny MJ"), local("SutonnyMJ Regular"),
        url("../fonts/SutonnyMJ.ttf") format("truetype");
    font-display: swap;
}

:root {
    --bg: #eef2f9;
    --bg-grad-1: #e7edfb;
    --bg-grad-2: #f3ecfb;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --border: #e2e8f2;
    --text: #1a2233;
    --text-soft: #55617a;
    --text-mute: #8a94a8;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eceafd;
    --accent: #0ea5a4;
    --danger: #e05656;
    --shadow: 0 10px 30px -12px rgba(30, 41, 89, 0.28);
    --shadow-sm: 0 2px 8px -3px rgba(30, 41, 89, 0.22);
    --radius: 16px;
    --radius-sm: 10px;
    --bn-font: "Hind Siliguri", "Noto Sans Bengali", "SolaimanLipi", sans-serif;
    --en-font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

[data-theme="dark"] {
    --bg: #0e1220;
    --bg-grad-1: #131a2e;
    --bg-grad-2: #1a1430;
    --surface: #171d2e;
    --surface-2: #1f2740;
    --border: #2a3350;
    --text: #e8ecf6;
    --text-soft: #aab3c9;
    --text-mute: #7a839b;
    --primary: #7c74ff;
    --primary-dark: #6a61f0;
    --primary-soft: #262a4d;
    --shadow: 0 14px 40px -16px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 2px 10px -4px rgba(0, 0, 0, 0.5);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--en-font);
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 15% -10%, var(--bg-grad-1), transparent 60%),
        radial-gradient(1000px 600px at 100% 0%, var(--bg-grad-2), transparent 55%),
        var(--bg);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

:lang(bn),
.badge,
.hero-sub,
.instruction-card,
.unicode-font {
    font-family: var(--bn-font);
}

.container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: saturate(160%) blur(10px);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    box-shadow: var(--shadow-sm);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-text strong {
    font-size: 16px;
}

.brand-text small {
    font-family: var(--bn-font);
    font-size: 12px;
    color: var(--text-mute);
}

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s, transform 0.2s;
}

.theme-toggle:hover {
    background: var(--surface-2);
    transform: translateY(-1px);
}

/* Hero */
.hero {
    text-align: center;
    padding: 42px 0 26px;
}

.hero h1 {
    font-size: clamp(1.6rem, 3.2vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(120deg, var(--text), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-sub {
    max-width: 760px;
    margin: 14px auto 0;
    color: var(--text-soft);
    font-size: 1.02rem;
}

/* Converter layout */
.converter {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 18px;
    align-items: stretch;
    margin-top: 8px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.panel-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.panel-title h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.badge {
    font-size: 11.5px;
    color: var(--text-mute);
    background: var(--primary-soft);
    color: var(--primary-dark);
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 600;
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.text-box {
    flex: 1;
    min-height: 300px;
    width: 100%;
    resize: vertical;
    border: none;
    outline: none;
    padding: 18px 16px;
    font-size: 1.15rem;
    line-height: 1.9;
    background: transparent;
    color: var(--text);
    font-family: var(--bn-font);
}

.text-box::placeholder {
    color: var(--text-mute);
    font-size: 0.95rem;
}

/* Render the Bijoy box in the SutonnyMJ font so ANSI text shows as Bangla */
#bijoyBox {
    font-family: "SutonnyMJ", var(--bn-font);
    font-size: 1.4rem;
    line-height: 2.1;
}

#bijoyBox::placeholder {
    font-family: var(--bn-font);
    font-size: 0.95rem;
    line-height: 1.6;
}

.panel-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 12.5px;
    color: var(--text-mute);
}

.preview-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.preview-toggle input {
    accent-color: var(--primary);
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.convert-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-family: var(--en-font);
    box-shadow: var(--shadow-sm);
    transition: all 0.18s ease;
    min-width: 140px;
    justify-content: center;
}

.convert-btn .lbl {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-align: left;
}

.convert-btn .lbl strong {
    font-size: 14px;
}

.convert-btn .lbl small {
    font-family: var(--bn-font);
    font-size: 11px;
    color: var(--text-mute);
}

.convert-btn .arrow {
    font-size: 15px;
    color: var(--primary);
}

.convert-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.convert-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-color: transparent;
}

.convert-btn.primary .lbl small,
.convert-btn.primary .arrow {
    color: rgba(255, 255, 255, 0.85);
}

.swap-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--primary);
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s ease, background 0.2s;
}

.swap-btn:hover {
    transform: rotate(180deg);
    background: var(--primary-soft);
}

/* Live preview */
.live-preview {
    margin-top: 18px;
}

.preview-panel {
    border: 1px solid var(--border);
}

.preview-controls {
    display: flex;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
}

.preview-controls .preview-toggle {
    margin: 0;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-soft);
    cursor: pointer;
    transition: all 0.15s ease;
}

.preview-controls .preview-toggle input {
    display: none;
}

.preview-controls .preview-toggle:has(input:checked) {
    background: var(--primary);
    color: #fff;
}

.live-preview-box {
    min-height: 120px;
    padding: 20px 18px;
    font-family: var(--bn-font);
    font-size: 1.5rem;
    line-height: 2;
    color: var(--text);
    word-break: break-word;
    white-space: pre-wrap;
}

.live-preview-box.sutonny-font {
    font-family: "SutonnyMJ", var(--bn-font);
    font-size: 1.7rem;
}

.live-preview-box:empty::before {
    content: attr(data-placeholder);
    color: var(--text-mute);
    font-size: 1rem;
    font-weight: 400;
}

.preview-hint {
    font-size: 12.5px;
    color: var(--text-mute);
    font-family: var(--bn-font);
}

/* Note */
.note {
    margin: 22px auto 0;
    max-width: 900px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    color: var(--text-soft);
    font-size: 0.92rem;
}

/* Instructions + SEO */
.instructions,
.seo-copy,
.faq {
    margin-top: 40px;
}

.instructions > h2,
.seo-copy > h2,
.faq > h2 {
    font-size: 1.3rem;
    margin-bottom: 16px;
    font-family: var(--bn-font);
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.instruction-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
}

.instruction-card h3 {
    margin-bottom: 10px;
    font-size: 1.05rem;
    color: var(--primary);
}

.instruction-card ol {
    padding-left: 20px;
    color: var(--text-soft);
}

.instruction-card li {
    margin-bottom: 6px;
}

.seo-copy p {
    color: var(--text-soft);
    max-width: 900px;
    margin-bottom: 12px;
    font-family: var(--bn-font);
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 900px;
}

.faq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.faq-item summary {
    cursor: pointer;
    padding: 16px 18px;
    font-weight: 600;
    font-family: var(--bn-font);
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: "+";
    font-size: 1.3rem;
    color: var(--primary);
    transition: transform 0.2s ease;
    line-height: 1;
}

.faq-item[open] summary::after {
    content: "\2212"; /* minus */
}

.faq-item p {
    padding: 0 18px 16px;
    color: var(--text-soft);
    font-family: var(--bn-font);
}

/* Footer */
.site-footer {
    margin-top: 56px;
    padding: 28px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-mute);
    font-size: 0.9rem;
}

.footer-sub {
    margin-top: 4px;
    font-size: 0.82rem;
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: var(--surface);
    padding: 11px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 50;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 860px) {
    .converter {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .convert-btn {
        flex: 1;
    }

    .swap-btn {
        order: -1;
        transform: rotate(90deg);
    }

    .swap-btn:hover {
        transform: rotate(270deg);
    }

    .text-box {
        min-height: 200px;
    }
}
