/* ==========================================================================
   PersamaanKata — one stylesheet, no build step.
   Identity: deep blue gradient, white serif wordmark, green synonym accent.
   ========================================================================== */

:root {
    --blue-900: #0b2a61;
    --blue-700: #123f8f;
    --blue-600: #1c56b5;
    --blue-500: #3578bc;
    --blue-100: #e6eefb;
    --green-600: #4f9144;
    --green-100: #e8f3e5;
    --red-600: #914444;
    --red-100: #f6e7e7;

    --bg: #f5f8fd;
    --surface: #ffffff;
    --surface-2: #eef3fa;
    --text: #13233f;
    --muted: #5b6b82;
    --border: #d7e1ef;
    --border-strong: #b9c9de;

    --link: #1250a8;
    --link-hover: #0b2a61;
    --focus: #ffb703;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(11, 42, 97, .06);
    --shadow: 0 2px 6px rgba(11, 42, 97, .07), 0 14px 34px rgba(11, 42, 97, .07);

    --wrap: 1080px;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: Georgia, "Times New Roman", "Noto Serif", serif;
}

:root[data-theme="dark"] {
    --bg: #0b1220;
    --surface: #121b2d;
    --surface-2: #17233a;
    --text: #e7eefc;
    --muted: #9fb0c9;
    --border: #24344f;
    --border-strong: #33486b;
    --link: #8ab6ff;
    --link-hover: #c3d9ff;
    --blue-100: #172642;
    --green-100: #172a1c;
    --red-100: #2c1a1a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 2px 8px rgba(0, 0, 0, .45), 0 18px 40px rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b1220;
        --surface: #121b2d;
        --surface-2: #17233a;
        --text: #e7eefc;
        --muted: #9fb0c9;
        --border: #24344f;
        --border-strong: #33486b;
        --link: #8ab6ff;
        --link-hover: #c3d9ff;
        --blue-100: #172642;
        --green-100: #172a1c;
        --red-100: #2c1a1a;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow: 0 2px 8px rgba(0, 0, 0, .45), 0 18px 40px rgba(0, 0, 0, .35);
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

a {
    color: var(--link);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover { color: var(--link-hover); }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.wrap {
    width: min(100% - 32px, var(--wrap));
    margin-inline: auto;
}

.visually-hidden {
    position: absolute !important;
    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;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    transition: top .15s ease;
}

.skip-link:focus { top: 12px; }

/* ---------------------------------------------------------------- header */

.site-header {
    background: linear-gradient(160deg, var(--blue-700) 0%, var(--blue-600) 55%, var(--blue-500) 100%);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .08), 0 8px 24px rgba(11, 42, 97, .18);
}

.header-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding-block: 14px;
    flex-wrap: wrap;
}

.brand { flex: 0 0 auto; line-height: 0; }
.brand img { height: 44px; width: auto; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex: 1 1 320px;
    justify-content: flex-end;
}

.search {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: min(100%, 420px);
    background: #fff;
    border-radius: 999px;
    padding: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

.search input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    color: #13233f;
    font: inherit;
    font-size: 16px;
    padding: 8px 14px;
    border-radius: 999px;
    outline: none;
}

.search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.search button {
    flex: 0 0 auto;
    border: 0;
    border-radius: 999px;
    padding: 8px 18px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--green-600);
    cursor: pointer;
}

.search button:hover { filter: brightness(1.08); }

.search--hero {
    width: min(100%, 620px);
    padding: 6px;
    box-shadow: var(--shadow);
}

.search--hero input[type="search"] { font-size: 18px; padding: 12px 18px; }
.search--hero button { padding: 12px 26px; font-size: 17px; }

.header-actions .search {
    flex: 1 1 auto;
    width: auto;
    max-width: 420px;
    min-width: 0;
}

.theme-toggle {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

.theme-toggle:hover { background: rgba(255, 255, 255, .22); }

.site-nav {
    border-top: 1px solid rgba(255, 255, 255, .16);
    background: rgba(0, 0, 0, .08);
}

.site-nav .wrap {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.site-nav a {
    display: inline-block;
    padding: 10px 14px;
    color: #eaf1ff;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}

.site-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, .08);
    border-bottom-color: var(--green-600);
}

/* ------------------------------------------------------------ structure */

.site-main {
    padding-block: 28px 48px;
}

h1, h2, h3 {
    font-family: var(--font-display);
    line-height: 1.25;
    color: var(--text);
}

h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); margin: 0 0 .5rem; }
h2 { font-size: 1.35rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .35rem; }

.breadcrumbs { margin-bottom: 14px; font-size: 14px; }
.breadcrumbs ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
    margin: 0;
    color: var(--muted);
}
.breadcrumbs li + li::before { content: "›"; margin-right: 6px; color: var(--border-strong); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--link); text-decoration: underline; }

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

.muted { color: var(--muted); }
.meta { color: var(--muted); font-size: 15px; margin: 0 0 18px; }

/* ------------------------------------------------------------------ home */

.hero {
    text-align: center;
    padding: clamp(24px, 6vw, 60px) 20px clamp(20px, 4vw, 40px);
    background:
        radial-gradient(1200px 300px at 50% -80px, var(--blue-100), transparent 70%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.hero h1 { margin-bottom: .4rem; }
.hero p { color: var(--muted); margin: 0 auto 22px; max-width: 60ch; }
.hero .search { margin-inline: auto; }

.stat-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 28px;
    margin-top: 18px;
    color: var(--muted);
    font-size: 15px;
}

.az-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.az-grid a {
    display: grid;
    place-items: center;
    height: 52px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.az-grid a:hover {
    border-color: var(--blue-500);
    color: var(--blue-600);
    background: var(--blue-100);
}

.home-section { margin-top: 34px; }
.home-section > h2 { margin-top: 0; }

.wotd {
    display: grid;
    gap: 8px;
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.wotd h3 { margin: 0; font-size: 1.5rem; }
.wotd .wotd-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* -------------------------------------------------------------- word page */

.word-header { margin-bottom: 14px; }
.word-header h1 { margin-bottom: .35rem; }
.word-header h1 i { color: var(--green-600); font-style: italic; }

.thesaurus-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}

.thesaurus-group > h2 {
    margin: 0 0 4px;
    font-size: 1.3rem;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--blue-100);
}

.thesaurus-type {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.syn-subgroup { margin-top: 14px; }
.syn-subgroup h3 {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin: 0 0 8px;
}

.syn-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.syn-list li { margin: 0; }

.syn-list a,
.syn-list span {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--blue-100);
    color: var(--blue-700);
    text-decoration: none;
    font-size: 15px;
    line-height: 1.4;
    border: 1px solid transparent;
}

.syn-list a:hover {
    background: var(--blue-700);
    color: #fff;
}

.syn-list .is-antonim { background: var(--red-100); color: var(--red-600); }
.syn-list .is-antonim:hover { background: var(--red-600); color: #fff; }

.syn-list .unlinked { color: var(--muted); background: var(--surface-2); }

.syn-note { font-size: 14px; color: var(--muted); margin: 4px 0 0; }

details.syn-more summary {
    cursor: pointer;
    color: var(--link);
    font-size: 14px;
    margin-top: 6px;
}

/* ----------------------------------------------------------- prefix page */

.prefix-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }

.prefix-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px 14px;
    list-style: none;
    padding: 0;
    margin: 18px 0;
}

.prefix-grid a {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
    overflow-wrap: anywhere;
}

.prefix-grid a:hover {
    background: var(--surface);
    border-color: var(--border);
    color: var(--blue-600);
}

.prefix-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }

.prefix-chips a {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}

.prefix-chips a:hover { color: var(--blue-600); border-color: var(--blue-500); }

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 24px 0 8px;
    font-size: 15px;
}

.pagination a,
.pagination span {
    min-width: 38px;
    text-align: center;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    color: var(--text);
}

.pagination a:hover { border-color: var(--blue-500); color: var(--blue-600); }
.pagination [aria-current="page"] { background: var(--blue-700); border-color: var(--blue-700); color: #fff; font-weight: 700; }
.pagination .disabled { color: var(--muted); background: transparent; border-color: transparent; }

/* ------------------------------------------------------------- search */

.no-results h1 { margin-bottom: 6px; }

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 10px 0 24px;
}

.chip-list a {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}

.chip-list a:hover { border-color: var(--blue-500); color: var(--blue-600); }

/* --------------------------------------------------------------- graph */

.graph-figure {
    margin: 0 0 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.graph-figure figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.graph-help { font-size: 13px; color: var(--muted); font-weight: 400; }

#synonym-graph {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: clamp(380px, 62vh, 680px);
    background:
        radial-gradient(circle at 50% 50%, var(--surface-2), var(--surface) 70%);
    overflow: hidden;
    touch-action: none;
}

#synonym-graph svg { display: block; flex: 1 1 auto; min-height: 0; width: 100%; height: 100%; cursor: grab; }
#synonym-graph svg.is-panning { cursor: grabbing; }

.graph-edge { stroke: var(--border-strong); stroke-width: 1.4; fill: none; }
.graph-edge.is-antonim { stroke: var(--red-600); stroke-dasharray: 6 4; }
.graph-edge.is-sinonim { stroke: var(--green-600); }
.graph-edge.is-related { stroke: var(--blue-500); }

.graph-node circle { stroke: var(--surface); stroke-width: 2; }
.graph-node text {
    font-family: var(--font-body);
    font-size: 13px;
    fill: var(--text);
    paint-order: stroke;
    stroke: var(--surface);
    stroke-width: 3px;
    pointer-events: none;
}
.graph-node.is-center text { font-size: 18px; font-weight: 700; }
.graph-node { cursor: pointer; }
.graph-node:focus-visible circle { stroke: var(--focus); stroke-width: 4; }

.graph-node .node-hit { fill: transparent; }

.graph-tooltip {
    position: absolute;
    z-index: 5;
    max-width: 280px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 14px;
    line-height: 1.45;
    pointer-events: none;
}

.graph-tooltip strong { display: block; font-size: 15px; }
.graph-tooltip .tt-meta { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

.graph-status {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    color: var(--muted);
    font-size: 14px;
}

.graph-toolbar {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.graph-toolbar button {
    min-width: 36px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.graph-toolbar button:hover { border-color: var(--blue-500); color: var(--blue-600); }

.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 10px 18px 14px;
    font-size: 13px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.graph-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.noscript-graph { padding: 12px 18px 18px; font-size: 14px; color: var(--muted); }
.noscript-graph svg { width: 100%; height: auto; }

/* ------------------------------------------------------------------ ads */

.ad-slot {
    margin: 26px 0;
    padding: 10px 12px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    min-height: 120px;
}

.ad-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    margin-bottom: 8px;
}

/* -------------------------------------------------------------- errors */

.error-state {
    max-width: 620px;
    margin: 40px auto;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 26px;
    box-shadow: var(--shadow-sm);
}

.error-links { margin-top: 18px; font-size: 15px; }

/* -------------------------------------------------------------- footer */

.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-block: 26px 34px;
    margin-top: 20px;
}

.az-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
}

.az-nav a {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
}

.az-nav a:hover { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }

.footer-links { display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--link); text-decoration: underline; }

.footer-copy { color: var(--muted); font-size: 13px; margin: 14px 0 0; max-width: 80ch; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 860px) {
    .header-bar { gap: 14px; padding-block: 12px; }
    .header-actions { flex-basis: 100%; justify-content: flex-start; }
    .header-actions .search { max-width: none; }
    .search { width: 100%; max-width: none; }
    #synonym-graph { height: clamp(320px, 55vh, 520px); }
}

@media (max-width: 560px) {
    body { font-size: 16px; }
    .wrap { width: min(100% - 22px, var(--wrap)); }
    .brand img { height: 36px; }
    .az-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
    .az-grid a { height: 44px; }
    .thesaurus-group { padding: 14px 16px; }
    .prefix-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .graph-help { display: none; }
}

@media print {
    .site-header, .site-footer, .ad-slot, .graph-toolbar, .theme-toggle { display: none; }
    body { background: #fff; color: #000; font-size: 12pt; }
}

/* ------------------------------------------------------------- utilities */

.button {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 999px;
    background: var(--blue-700);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}

.button:hover { background: var(--blue-900); color: #fff; }

.graph-label.is-collapsed { display: none; }

.graph-node { outline: none; }

/* Internal links to tools from dictionary pages */
.tool-crosslinks ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
}

.tool-crosslinks a {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
}

.tool-crosslinks a:hover { border-color: var(--blue-500); color: var(--blue-600); }
