/* UG Blog — editorial theme. Plain CSS, no build step. */

:root {
    --paper: #fbfaf7;
    --paper-2: #f3f0ea;
    --card: #ffffff;
    --ink: #17171a;
    --ink-2: #45454d;
    --muted: #7a7a83;
    --line: #e4e0d8;
    --brand: #ed1c24;
    --brand-ink: #c4161c;
    --brand-soft: #fdeceb;
    --steel: #939598;
    --focus: #2f6fed;

    --serif: "Noto Serif Georgian", "Noto Serif", Georgia, serif;
    --sans: "Noto Sans Georgian", "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

    --radius: 14px;
    --wrap: 1200px;
    --shadow: 0 1px 2px rgb(20 20 30 / .04), 0 8px 24px rgb(20 20 30 / .06);
    color-scheme: light;
}

/* dark palette: follows the system unless the visitor picked a theme (html[data-theme]) */
:root[data-theme="dark"] {
    --paper: #121214;
    --paper-2: #1a1a1d;
    --card: #1c1c20;
    --ink: #f2f0ec;
    --ink-2: #c9c7c2;
    --muted: #8f8d89;
    --line: #2c2c31;
    --brand: #ff3b42;
    --brand-ink: #ff5a60;
    --brand-soft: #2a1617;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #121214;
        --paper-2: #1a1a1d;
        --card: #1c1c20;
        --ink: #f2f0ec;
        --ink-2: #c9c7c2;
        --muted: #8f8d89;
        --line: #2c2c31;
        --brand: #ff3b42;
        --brand-ink: #ff5a60;
        --brand-soft: #2a1617;
        --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
        color-scheme: dark;
    }
}

.theme-toggle {
    display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--line); border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-2); }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

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

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */

.topbar {
    font-size: 13px;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 40px; }
.topbar-links { display: flex; align-items: center; gap: 18px; }
.topbar a:hover { color: var(--ink); }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang a { padding: 2px 10px; font-weight: 600; letter-spacing: .04em; }
.lang a.active { background: var(--ink); color: var(--paper); }

.masthead { padding: 28px 0 22px; text-align: center; }
.brand { display: inline-flex; align-items: center; gap: 14px; }
.brand img { width: 52px; height: 52px; }
.brand-name {
    font-family: var(--serif);
    font-size: clamp(28px, 4.5vw, 44px);
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.1;
}
.brand-name span { color: var(--brand); }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

.nav {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; gap: 12px; height: 52px; }
.nav-links {
    display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; min-width: 0;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a, .nav-more summary {
    white-space: nowrap; padding: 6px 12px; border-radius: 999px;
    font-size: 14.5px; font-weight: 500; color: var(--ink-2);
}
.nav-links a:hover, .nav-more summary:hover, .nav-more[open] summary { background: var(--paper-2); color: var(--ink); }
.nav-links a.active, .nav-more summary.active { background: var(--ink); color: var(--paper); }

.nav-more { position: relative; flex: none; }
.nav-more summary {
    display: inline-flex; align-items: center; gap: 4px; cursor: pointer; list-style: none;
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary svg { width: 16px; height: 16px; transition: transform .15s ease; }
.nav-more[open] summary svg { transform: rotate(180deg); }
.nav-menu {
    position: absolute; top: calc(100% + 10px); left: 0; z-index: 30;
    min-width: 260px; max-height: min(70vh, 460px); overflow-y: auto;
    padding: 6px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--card); box-shadow: var(--shadow);
}
.nav-menu a {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 9px 12px; border-radius: 8px; font-size: 14.5px; color: var(--ink-2);
}
.nav-menu a:hover { background: var(--paper-2); color: var(--ink); }
.nav-menu a.active { color: var(--brand-ink); font-weight: 600; }
.nav-menu small { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.nav .search { margin-left: auto; }
.nav-menu a.menu-primary, .nav-more.only-mobile { display: none; }

.search { position: relative; flex: 0 0 auto; }
.search input {
    width: 200px; height: 36px; padding: 0 12px 0 34px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--card); color: var(--ink); font: inherit; font-size: 14px;
    transition: width .2s ease;
}
.search input:focus { width: 260px; outline: none; border-color: var(--ink-2); }
.search svg { position: absolute; left: 11px; top: 10px; width: 16px; height: 16px; color: var(--muted); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
    font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { border-color: var(--line); background: var(--card); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }

/* ---------- Common bits ---------- */

.eyebrow {
    display: inline-block;
    font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--brand-ink);
}
a.eyebrow:hover { text-decoration: underline; text-underline-offset: 3px; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13.5px; color: var(--muted); }
.meta .dot::before { content: "·"; }
.meta a:hover { color: var(--ink); }

.avatar {
    width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none;
    display: inline-grid; place-items: center;
    background: var(--paper-2); color: var(--ink-2); font-size: 12px; font-weight: 700;
}
.avatar-lg { width: 96px; height: 96px; font-size: 32px; border: 4px solid var(--paper); }
.byline { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 500; }

.section-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
    margin: 0 0 20px; padding-bottom: 10px; border-bottom: 2px solid var(--ink);
}
.section-head h2 { margin: 0; font-family: var(--serif); font-size: 24px; line-height: 1.2; }
.section-head a { font-size: 14px; font-weight: 600; color: var(--brand-ink); }
.section-head a:hover { text-decoration: underline; text-underline-offset: 3px; }

.thumb {
    position: relative; overflow: hidden; border-radius: var(--radius);
    background: var(--paper-2); aspect-ratio: 16 / 10;
}
.thumb img { position: relative; width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
a:hover .thumb img { transform: scale(1.03); }
.thumb-fallback {
    position: absolute; inset: 0; display: grid; place-items: center;
    background:
        radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 55%),
        radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--steel) 30%, transparent), transparent 55%),
        var(--paper-2);
    font-family: var(--serif); font-size: 64px; font-weight: 700; color: color-mix(in srgb, var(--ink) 20%, transparent);
}

/* ---------- Home ---------- */

main { padding: 36px 0 72px; }

.hero {
    display: grid; grid-template-columns: 1.35fr 1fr; gap: 40px; align-items: center;
    margin-bottom: 56px;
}
.hero .thumb { aspect-ratio: 4 / 3; border-radius: 18px; }
.hero h1 {
    margin: 12px 0 14px;
    font-family: var(--serif); font-size: clamp(28px, 3.4vw, 42px); line-height: 1.18; letter-spacing: -.01em;
}
.hero h1 a:hover { color: var(--brand-ink); }
.hero p { margin: 0 0 20px; color: var(--ink-2); font-size: 18px; }

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px 28px; }
.card h3 {
    margin: 14px 0 8px; font-family: var(--serif); font-size: 20px; line-height: 1.3;
}
.card a:hover h3 { color: var(--brand-ink); }
.card p { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }
.card .eyebrow { margin-top: 14px; }
.card .eyebrow + h3 { margin-top: 6px; }

.ranked { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.ranked li { display: grid; grid-template-columns: 40px 1fr; gap: 6px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.ranked li:first-child { padding-top: 0; }
.ranked li::before {
    counter-increment: rank; content: counter(rank, decimal-leading-zero);
    font-family: var(--serif); font-size: 22px; font-weight: 700; color: var(--brand); line-height: 1.2;
}
.ranked h4 { margin: 0 0 4px; font-family: var(--serif); font-size: 16.5px; line-height: 1.35; }
.ranked a:hover h4 { color: var(--brand-ink); }

.cta {
    margin-top: 32px; padding: 26px; border-radius: var(--radius);
    background: var(--ink); color: var(--paper);
}
.cta h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 22px; }
.cta p { margin: 0 0 18px; color: color-mix(in srgb, var(--paper) 75%, transparent); font-size: 15px; }

.cat-sections { display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px; margin-top: 64px; }
.cat-sections .card h3 { font-size: 17.5px; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.cat-list li:first-child { padding-top: 0; }
.cat-list h4 { margin: 0 0 4px; font-family: var(--serif); font-size: 16.5px; line-height: 1.35; }
.cat-list a:hover h4 { color: var(--brand-ink); }

/* ---------- Listing ---------- */

.page-head { margin-bottom: 36px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin: 8px 0 6px; font-family: var(--serif); font-size: clamp(30px, 4vw, 46px); line-height: 1.15; }
.page-head p { margin: 0; max-width: 720px; color: var(--ink-2); }

.empty { padding: 64px 0; text-align: center; color: var(--muted); }

.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 56px; }
.pagination a, .pagination span {
    min-width: 40px; height: 40px; padding: 0 12px; display: inline-grid; place-items: center;
    border: 1px solid var(--line); border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--card);
}
.pagination a:hover { border-color: var(--ink-2); }
.pagination .current { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pagination .disabled { color: var(--muted); opacity: .5; }

/* ---------- Article ---------- */

.article-head { max-width: 820px; margin: 0 auto 32px; text-align: center; }
.article-head h1 {
    margin: 14px 0 16px; font-family: var(--serif);
    font-size: clamp(30px, 4.6vw, 52px); line-height: 1.15; letter-spacing: -.015em;
}
.article-head .dek { margin: 0 auto 22px; max-width: 680px; font-size: 20px; color: var(--ink-2); }
.article-head .meta { justify-content: center; }

.article-cover { max-width: 1040px; margin: 0 auto 44px; }
.article-cover img { width: 100%; max-height: 620px; object-fit: cover; border-radius: 18px; }

.prose {
    max-width: 700px; margin: 0 auto;
    font-family: var(--serif); font-size: 19px; line-height: 1.8; color: var(--ink);
    overflow-wrap: break-word;
}
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.3em; }
.prose h2, .prose h3, .prose h4 { font-family: var(--serif); line-height: 1.3; margin: 1.8em 0 .6em; }
.prose h2 { font-size: 28px; }
.prose h3 { font-size: 23px; }
.prose a { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose img { margin: 1.6em auto; border-radius: 10px; height: auto !important; }
/* legacy posts float images with align="left|right" or inline float styles */
.prose img[align="left" i], .prose img[style*="float: left"], .prose img[style*="float:left"] {
    float: left; max-width: 45%; margin: .35em 1.75em 1em 0;
}
.prose img[align="right" i], .prose img[style*="float: right"], .prose img[style*="float:right"] {
    float: right; max-width: 45%; margin: .35em 0 1em 1.75em;
}
.prose::after { content: ""; display: block; clear: both; }
/* justified Georgian text in a narrow column leaves big gaps between words */
.prose [style*="justify"], .prose [align="justify" i] { text-align: left !important; }
.prose figure { margin: 1.8em 0; }
.prose figcaption { font-family: var(--sans); font-size: 14px; color: var(--muted); text-align: center; margin-top: 8px; }
.prose blockquote {
    margin: 1.8em 0; padding: 4px 0 4px 24px; border-left: 3px solid var(--brand);
    font-style: italic; color: var(--ink-2);
}
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.3em; }
.prose li { margin: .3em 0; }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2.4em 0; }
.prose table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 15px; margin: 1.6em 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.prose pre { background: var(--paper-2); padding: 16px; border-radius: 10px; overflow-x: auto; font-size: 14px; }
/* legacy TinyMCE posts carry inline fonts and colours; let the theme win */
.prose [style] { font-family: inherit !important; font-size: inherit !important; background-color: transparent !important; color: inherit !important; }
.prose span[style], .prose p[style] { line-height: inherit !important; }

.article-foot { max-width: 700px; margin: 48px auto 0; display: grid; gap: 28px; }

.rate-box {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px;
    padding: 18px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
}
.rate-box strong { display: block; font-size: 15px; }
.rate-box small { color: var(--muted); font-size: 13px; }
.stars { display: inline-flex; gap: 2px; }
.stars button {
    width: 34px; height: 34px; padding: 0; border: 0; background: none; cursor: pointer;
    color: var(--line); transition: transform .1s ease, color .1s ease;
}
.stars button svg { width: 100%; height: 100%; }
.stars button.on, .stars:not([data-locked]):hover button { color: #f5a623; }
.stars:not([data-locked]) button:hover ~ button { color: var(--line); }
.stars button:hover { transform: scale(1.1); }
.stars[data-locked] button { cursor: default; }

.share { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }

.author-box {
    display: grid; grid-template-columns: 64px 1fr; gap: 18px; align-items: center;
    padding: 22px; border-radius: var(--radius); background: var(--paper-2);
}
.author-box .avatar { width: 64px; height: 64px; font-size: 22px; }
.author-box h4 { margin: 0 0 4px; font-size: 17px; }
.author-box p { margin: 0; font-size: 14.5px; color: var(--ink-2); }

.related { margin-top: 72px; padding-top: 40px; border-top: 1px solid var(--line); }

.comments { max-width: 700px; margin: 64px auto 0; }
.comments h2 { font-family: var(--serif); font-size: 26px; margin: 0 0 22px; }
.comment { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.comment .avatar { width: 40px; height: 40px; font-size: 15px; }
.comment-name { font-weight: 600; font-size: 15px; }
.comment-date { font-size: 13px; color: var(--muted); margin-left: 6px; }
.comment-body { margin: 4px 0 0; font-size: 15.5px; color: var(--ink-2); white-space: pre-line; }

.form { display: grid; gap: 14px; margin-top: 28px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.form h3 { margin: 0; font-size: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--paper); color: var(--ink); font: inherit; font-size: 15px;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ink-2); }
.field .error { margin-top: 4px; color: var(--brand-ink); font-size: 13px; }
.hp { position: absolute; left: -9999px; }

.alert { padding: 14px 18px; border-radius: 10px; font-size: 15px; margin-bottom: 20px; }
.alert-success { background: color-mix(in srgb, #1f9d55 12%, var(--card)); color: color-mix(in srgb, #1f9d55 70%, var(--ink)); }
.alert-error { background: var(--brand-soft); color: var(--brand-ink); }

.lang-note {
    max-width: 700px; margin: 0 auto 28px; padding: 12px 16px; border-radius: 10px;
    background: var(--paper-2); color: var(--ink-2); font-size: 15px; text-align: center;
}

/* ---------- Author page ---------- */

.profile-cover {
    height: 260px; border-radius: 18px; overflow: hidden;
    background: linear-gradient(135deg, var(--ink) 0%, #3a3a42 60%, var(--brand) 140%);
}
.profile-cover img { width: 100%; height: 100%; object-fit: cover; }
.profile-head { display: flex; align-items: flex-start; gap: 20px; margin: -48px 0 36px 28px; }
/* only the avatar overlaps the cover; the text starts just below it */
.profile-head > div { padding-top: 60px; min-width: 0; }
.profile-head h1 { margin: 0 0 4px; font-family: var(--serif); font-size: 32px; line-height: 1.2; }
.profile-head p { margin: 0; color: var(--ink-2); max-width: 640px; }

/* ---------- Footer ---------- */

.footer { border-top: 1px solid var(--line); background: var(--paper-2); padding: 48px 0 28px; font-size: 14.5px; color: var(--ink-2); }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 40px; }
.footer h5 { margin: 0 0 12px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer a:hover { color: var(--brand-ink); }
.footer .brand img { width: 40px; height: 40px; }
.footer .brand-name { font-size: 24px; }
.footer-bottom { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero { grid-template-columns: 1fr; gap: 24px; }
    .home-grid { grid-template-columns: 1fr; }
    .cat-sections { grid-template-columns: 1fr; gap: 44px; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-grid > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .prose img[align], .prose img[style*="float"] { float: none; max-width: 100%; margin: 1.4em auto; }
    .cards { grid-template-columns: 1fr; }
    .nav-menu { left: auto; right: 0; min-width: 230px; }
    .nav-links .nav-primary { display: none; }
    .nav .wrap { gap: 6px; }
    .nav-links a, .nav-more summary { padding: 6px 9px; font-size: 14px; }
    .nav-more.only-mobile { display: block; }
    .nav-menu a.menu-primary { display: flex; }
    .nav-more summary.active-mobile { background: var(--ink); color: var(--paper); }
    body { font-size: 16px; }
    .wrap { padding: 0 16px; }
    .topbar .date { display: none; }
    .masthead { padding: 20px 0 16px; }
    .brand img { width: 40px; height: 40px; }
    .tagline { display: none; }
    .search input, .search input:focus { width: 40px; padding-right: 0; cursor: pointer; }
    .search input:focus { width: 170px; padding-right: 12px; cursor: text; }
    .prose { font-size: 17.5px; }
    .article-head .dek { font-size: 18px; }
    .form-row { grid-template-columns: 1fr; }
    .profile-cover { height: 160px; }
    .profile-head { flex-direction: column; align-items: flex-start; margin-left: 12px; }
    .profile-head > div { padding-top: 0; }
    .footer-grid { grid-template-columns: 1fr; }
}
