/* dict.css — gokanji dictionary stylesheet
 * Version: 3.10 2026-02-19 (Kanji Lookup page — search form, result grid, improved radical picker)
 * Matches the original gokanji.com interface: dense, flowing, color-coded.
 */

:root {
    --bg: #1a2744;
    --bg-input: #0e1a2e;
    --text: #ddd;
    --text-light: #aaa;
    --text-muted: #778;
    --yellow: #ee0;
    --cyan: #0ee;
    --green: #6d6;
    --red: #e44;
    --orange: #fa3;
    --link: #5cf;
    --link-visited: #9cf;
    --common: #5d5;
    --pos-color: #e6e;
    --hint: #fa0;
    --border: #2a3a55;
    --border-light: #253550;
    --tag-bg: #253050;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    padding: 8px 16px;
    min-height: 100vh;
}

.jp {
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic Pro", "Yu Gothic", "Meiryo", sans-serif;
}

/* --- Links --- */

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--link-visited); }

/* --- Header (flowing, no border box) --- */

header {
    margin-bottom: 4px;
}

h1.site-title {
    font-size: 28px;
    font-weight: bold;
    margin: 0 0 2px 0;
    line-height: 1.3;
    color: var(--yellow);
}

h1.site-title .jp-title { font-size: 30px; }

.title-link, .title-link:visited {
    color: var(--yellow);
    text-decoration: none;
}

nav {
    font-size: 12px;
    margin-bottom: 4px;
}

nav a {
    margin-right: 16px;
    white-space: nowrap;
}

/* --- Main --- */

main { }

/* --- Footer (flowing inline text) --- */

footer {
    margin-top: 16px;
    padding-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

footer a { color: var(--text-light); }
footer div { margin-bottom: 2px; }

/* --- Color utility classes (WWWJDIC hierarchy) --- */

.color-cyan { color: var(--cyan); }
.color-green { color: var(--green); }
.color-red { color: var(--red); }
.color-orange { color: var(--orange); }
.color-yellow { color: var(--yellow); }

/* --- Flowing form (no fieldsets, no control panels) --- */

.dict-form {
    margin-bottom: 8px;
}

/* --- Welcome / info text --- */

.welcome-text {
    color: var(--cyan);
    font-style: italic;
    margin-bottom: 4px;
}

.instruction-text {
    color: var(--green);
    font-size: 13px;
    margin-bottom: 8px;
}

/* --- Dictionary checkboxes in brackets --- */

.dict-bracket {
    font-size: 13px;
    margin-bottom: 6px;
    line-height: 1.8;
}

.dict-bracket-label {
    color: var(--green);
    font-weight: bold;
}

.dict-bracket label {
    white-space: nowrap;
    cursor: pointer;
}

/* --- Section headers (red/orange like original) --- */

.section-header {
    color: var(--red);
    font-size: 20px;
    font-weight: bold;
    font-style: italic;
    margin: 10px 0 6px 0;
}

/* --- Search form row (flowing) --- */

.search-row {
    font-size: 13px;
    margin-bottom: 4px;
    line-height: 2;
}

.search-row select {
    font-size: 13px;
    padding: 1px 4px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
}

.search-input {
    font-size: 14px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    width: 200px;
}

.search-input:focus {
    outline: 2px solid var(--link);
    outline-offset: -1px;
}

.search-btn {
    padding: 2px 12px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--yellow);
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
}

.search-btn:hover { background: var(--border); }

/* --- Options row (flowing inline) --- */

.options-row {
    font-size: 13px;
    margin-bottom: 4px;
    line-height: 2;
}

.options-row label {
    cursor: pointer;
    white-space: nowrap;
}

.options-row select {
    font-size: 13px;
    padding: 1px 4px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
}

/* --- Display toggles in brackets --- */

.display-bracket {
    font-size: 13px;
    margin-bottom: 6px;
    line-height: 2;
}

.display-bracket label {
    white-space: nowrap;
    cursor: pointer;
}

/* --- News items --- */

.news-label {
    color: var(--red);
    font-weight: bold;
}

.news-item {
    margin-bottom: 2px;
    font-size: 13px;
}

/* --- Notes section --- */

.notes-header {
    color: var(--red);
    font-size: 20px;
    font-weight: bold;
    margin: 12px 0 4px 0;
}

.notes-intro {
    color: var(--orange);
    font-size: 13px;
    margin-bottom: 4px;
}

/* --- Home info/stats --- */

.home-info {
    margin-top: 8px;
}

.home-stats {
    font-size: 13px;
    color: var(--cyan);
}

.home-links {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

/* --- Result info bar --- */

.result-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}

/* --- Result group headers --- */

.result-group-header {
    font-size: 14px;
    font-weight: bold;
    color: var(--cyan);
    margin: 8px 0 4px 0;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border-light);
}

/* --- Result list (dense text lines) --- */

.result-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.result-line {
    padding: 2px 0;
    border-bottom: 1px solid var(--border-light);
    line-height: 1.5;
}

.result-line:last-child { border-bottom: none; }

.r-headword {
    font-weight: bold;
    font-size: 15px;
}

.r-alt { color: var(--text-light); font-size: 13px; }

.r-reading { color: var(--text-light); }

.r-romaji {
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
}

.r-common {
    color: var(--common);
    font-size: 11px;
    font-weight: bold;
}

.r-pos {
    color: var(--pos-color);
    font-size: 11px;
    font-family: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
}

.r-gloss { color: var(--text); }

.r-more {
    color: var(--text-muted);
    font-size: 11px;
}

/* --- Kanji decomposition in name results --- */

.r-decomp {
    font-size: 11px;
    color: var(--text-muted);
}

.decomp-char {
    cursor: help;
}

/* --- Kanji breakdown on detail pages --- */

.kanji-breakdown {
    list-style: none;
    padding: 0;
    margin: 0;
}

.kanji-breakdown-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.kanji-breakdown-item:last-child { border-bottom: none; }

.kanji-breakdown-char {
    font-size: 32px;
    line-height: 1;
    min-width: 40px;
    text-align: center;
    text-decoration: none;
}

.kanji-breakdown-char:hover { background: rgba(255,255,255,0.05); }

.kanji-breakdown-info { font-size: 13px; }

.kanji-breakdown-meanings { font-weight: bold; margin-bottom: 2px; color: var(--yellow); }

.kanji-breakdown-readings { color: var(--text-light); }

.kanji-reading-label {
    font-weight: bold;
    font-size: 11px;
    color: var(--cyan);
}

.kanji-breakdown-meta {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Kanji links in results --- */

.kanji-link {
    font-weight: bold;
    font-size: 15px;
}

.kanji-link:hover {
    background: rgba(255,255,255,0.05);
}

/* --- Tags / badges --- */

.tag {
    display: inline-block;
    font-size: 11px;
    padding: 0 4px;
    background: var(--tag-bg);
    color: var(--text-light);
    border-radius: 2px;
    margin-right: 2px;
}

.tag-common { background: #1a3a1a; color: var(--common); }
.tag-name-surname { background: #1a2540; color: #6af; }
.tag-name-given, .tag-name-fem, .tag-name-masc { background: #1a3a1a; color: var(--common); }
.tag-name-place { background: #3a2a10; color: #fa0; }
.tag-name-person { background: #2a1a3a; color: #c8f; }

/* --- Pagination --- */

.pagination {
    font-size: 13px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.pagination a, .pagination span {
    padding: 2px 8px;
    margin: 0 1px;
}

.pagination .current {
    font-weight: bold;
    background: var(--tag-bg);
    color: var(--yellow);
}

/* --- Detail pages --- */

.detail-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.detail-headword {
    font-size: 28px;
    font-weight: bold;
    line-height: 1.2;
    color: var(--yellow);
}

.detail-reading {
    font-size: 18px;
    color: var(--cyan);
    margin-top: 2px;
}

/* --- Sense list --- */

.sense-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: sense;
}

.sense-item {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
}

.sense-item:last-child { border-bottom: none; }

.sense-num {
    color: var(--text-muted);
    font-weight: bold;
    margin-right: 4px;
}

.sense-field {
    color: var(--hint);
    font-size: 11px;
    font-family: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
}

/* --- Kanji detail --- */

.kanji-large {
    font-size: 72px;
    line-height: 1;
    float: left;
    margin-right: 16px;
    margin-bottom: 8px;
    color: #fff;
}

.kanji-meta { font-size: 13px; color: var(--text-light); }
.kanji-meta dt { display: inline; font-weight: bold; color: var(--cyan); }
.kanji-meta dt::after { content: ": "; }
.kanji-meta dd { display: inline; margin: 0; }
.kanji-meta dd::after { content: ""; display: block; }

.clearfix::after { content: ""; display: table; clear: both; }

/* --- Kanji search form --- */

.kanji-search-form {
    margin-bottom: 12px;
}

.kanji-search-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 6px;
    font-size: 13px;
}

.kanji-search-fields label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-input-sm {
    width: 70px;
}

.kanji-search-filters {
    font-size: 13px;
    line-height: 2;
    margin-bottom: 6px;
}

.kanji-search-filters label {
    white-space: nowrap;
    cursor: pointer;
}

.kanji-search-filters select {
    font-size: 13px;
    padding: 1px 4px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
}

.kanji-search-actions {
    margin-bottom: 8px;
}

.kanji-search-results {
    margin-bottom: 16px;
}

/* --- Kanji result grid (shared by search + radical picker) --- */

.kanji-result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 6px;
}

.kanji-result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 6px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.kanji-result-card:visited { color: var(--text); }

.kanji-result-card:hover {
    border-color: var(--text-muted);
    background: var(--border);
}

.kanji-result-char {
    font-size: 32px;
    line-height: 1.1;
    color: #fff;
}

.kanji-result-readings {
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    margin-top: 2px;
}

.kanji-result-meaning {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.kanji-result-strokes {
    font-size: 10px;
    color: var(--text-muted);
}

/* --- Radical picker (improved grid) --- */

.radical-stroke-label {
    font-size: 11px;
    color: var(--cyan);
    margin-top: 8px;
    margin-bottom: 2px;
    font-weight: bold;
}

.radical-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 3px;
    max-width: 600px;
}

.radical-cell {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    font-size: 20px;
    font-family: "Noto Sans JP", sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: border-color 0.15s, background 0.15s;
}

.radical-cell:hover {
    background: var(--border);
    border-color: var(--text-muted);
}

.radical-cell.selected {
    background: #063;
    color: var(--yellow);
    border-color: var(--common);
    box-shadow: 0 0 0 2px var(--common);
}

/* --- Selected radicals display --- */

.selected-radicals {
    font-size: 13px;
    margin-bottom: 8px;
    padding: 4px 0;
}

.selected-radicals .badge {
    display: inline-block;
    font-size: 16px;
    padding: 0 6px;
    background: #063;
    color: var(--yellow);
    margin-right: 2px;
}

/* --- Example sentences --- */

.example {
    padding: 2px 0 2px 16px;
    border-left: 2px solid var(--border);
    margin: 4px 0;
    font-size: 13px;
}

.example-jp { color: var(--text); }
.example-en { color: var(--text-light); }

/* --- Credits (about page) --- */

.credits dt {
    font-weight: bold;
    margin-top: 12px;
    color: var(--yellow);
}

.credits dd {
    margin: 2px 0 0 0;
    color: var(--text-light);
}

/* --- About page history --- */

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-list li {
    padding: 3px 0;
    border-bottom: 1px solid var(--border-light);
}

.history-list li:last-child { border-bottom: none; }

.history-date {
    color: var(--cyan);
    font-weight: bold;
    font-family: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
    font-size: 12px;
}

/* --- Breadcrumb --- */

.breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* --- Error pages --- */

.error-page {
    text-align: center;
    padding: 48px 0;
}

.error-code {
    font-size: 48px;
    color: var(--yellow);
    font-weight: bold;
}

/* --- Section headings --- */

h2 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--cyan);
}

h3 {
    font-size: 14px;
    margin: 16px 0 4px 0;
    color: var(--cyan);
}

/* --- Utility --- */

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* --- More fields collapsible --- */

.domain-more {
    font-size: 13px;
    margin-top: 2px;
}

.domain-more summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
}

.domain-more summary:hover {
    color: var(--text);
}

.domain-more-inner {
    line-height: 1.8;
    margin-top: 2px;
}

.domain-more-inner label {
    white-space: nowrap;
    cursor: pointer;
}

/* --- Mobile --- */

@media (max-width: 600px) {
    body {
        font-size: 13px;
        padding: 4px 8px;
    }

    h1.site-title { font-size: 20px; }
    h1.site-title .jp-title { font-size: 22px; }

    .search-input {
        width: 100%;
        font-size: 16px; /* prevents iOS zoom */
    }

    .kanji-large {
        font-size: 48px;
        margin-right: 12px;
    }

    .detail-headword { font-size: 22px; }

    nav a { margin-right: 12px; }

    .radical-cell {
        font-size: 16px;
    }

    .radical-picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    }

    .kanji-search-fields {
        flex-direction: column;
        gap: 6px;
    }

    .kanji-search-fields .search-input {
        width: 100%;
    }

    .kanji-result-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    }
}
