/* translit.dev — Minimal, professional transliteration tool */

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e0e0e0;
    --text: #1a1a1a;
    --text-muted: #666666;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
    --transition: 150ms ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f0f0f;
        --surface: #1a1a1a;
        --border: #2a2a2a;
        --text: #e5e5e5;
        --text-muted: #999999;
        --accent: #60a5fa;
        --accent-hover: #93bbfd;
        --accent-light: #1e293b;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
    }
}

/* ── Accessibility utilities ───────────────────────── */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 200;
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
    top: 0;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Layout ────────────────────────────────────────── */

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

header {
    padding: 1.5rem 0 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

header h1 span {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

/* ── Controls bar ──────────────────────────────────── */

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

select {
    appearance: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: var(--font-sans);
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23666' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.swap-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: all var(--transition);
    align-self: flex-end;
}

.swap-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ── Mode toggle ───────────────────────────────────── */

.mode-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.mode-btn {
    padding: 0.45rem 0.75rem;
    border: none;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.mode-btn + .mode-btn {
    border-left: 1px solid var(--border);
}

.mode-btn:hover {
    color: var(--text);
}

.mode-btn.active {
    background: var(--accent);
    color: #fff;
}

/* ── Text panes ────────────────────────────────────── */

.panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.pane {
    position: relative;
    display: flex;
    flex-direction: column;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.25rem;
}

.pane-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.char-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

textarea, .output-area {
    width: 100%;
    height: 400px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--surface);
    resize: none;
    transition: border-color var(--transition);
    overflow-y: auto;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.output-area {
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.pane-action-btn {
    position: absolute;
    top: 1.75rem;
    right: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-sans);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
}

.pane-action-btn .btn-label {
    line-height: 1;
}

.pane:hover .pane-action-btn {
    opacity: 1;
}

.pane-action-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.copy-btn.copied {
    color: #16a34a;
    border-color: #16a34a;
}

/* ── Script detection badge ────────────────────────── */

.script-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    background: var(--accent-light);
    color: var(--accent);
    margin-left: 0.5rem;
    font-weight: 500;
}

/* ── Mapping table ─────────────────────────────────── */

.mapping-section {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-bottom: 2rem;
}

.mapping-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-sans);
    padding: 0.25rem 0;
}

.mapping-toggle::before {
    content: '▶';
    font-size: 0.65rem;
    transition: transform var(--transition);
    display: inline-block;
}

.mapping-toggle.open::before {
    transform: rotate(90deg);
}

.mapping-table-wrap {
    display: none;
    margin-top: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.mapping-table-wrap.open {
    display: block;
}

.mapping-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.mapping-table th {
    position: sticky;
    top: 0;
    background: var(--surface);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.mapping-table td {
    padding: 0.35rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.mapping-table tr:last-child td {
    border-bottom: none;
}

.mapping-table tr:hover {
    background: var(--accent-light);
}

.mapping-table .char-col {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    width: 60px;
    text-align: center;
}

.mapping-table .code-col {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 80px;
}

.mapping-table .result-col {
    font-family: var(--font-mono);
}

/* ── Passthrough warning ──────────────────────────── */

.passthrough-warning {
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    background: #fef3c7;
    color: #92400e;
    font-size: 0.85rem;
    line-height: 1.5;
}

.passthrough-warning.hidden {
    display: none;
}

@media (prefers-color-scheme: dark) {
    .passthrough-warning {
        background: #451a03;
        border-color: #b45309;
        color: #fbbf24;
    }
}

/* ── SEO description text ──────────────────────────── */

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

.seo-text p {
    margin-bottom: 0.5rem;
}

/* ── Loading state ─────────────────────────────────── */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 300ms ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ── Footer ────────────────────────────────────────── */

footer {
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ── Focus-visible for keyboard navigation ──────────── */

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

select:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.mode-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.output-area:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 640px) {
    .panes {
        grid-template-columns: 1fr;
    }

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

    .control-group {
        width: 100%;
    }

    select {
        width: 100%;
    }

    .swap-btn {
        align-self: center;
        transform: rotate(90deg);
    }

    header h1 span {
        display: block;
        margin-left: 0;
        margin-top: 0.25rem;
    }
}
