/* Roundel — static site stylesheet
   roundel.yenerunsal.com

   Design notes:
   - Roundel blue (#0066B1), the BMW roundel tone, as the single accent.
   - System font stack: no webfont download, and every locale (ar/ja/ko/zh/ru)
     renders in a face the OS actually ships. Speed + correct glyphs.
   - Mobile-first and fluid: every size that matters is clamp()-based, so the
     layout is continuous from 320px to ultrawide instead of jumping at
     breakpoints. Breakpoints only handle structural changes.
   - No JavaScript anywhere. The language switcher is a <details> element.
   - Flags are inline SVG (see FLAG_SPRITE in build-site.py), never emoji:
     Windows ships no colour flag emoji, so emoji flags are invisible to a
     large share of desktop visitors.
*/

:root {
    --roundel-blue: #0066B1;
    --roundel-blue-hover: #00507F;
    --roundel-blue-light: #EAF2F9;
    --accent-ring: rgba(0, 102, 177, 0.35);

    --text: #14171A;
    --text-muted: #5B6570;
    --border: #E3E7EB;
    --border-soft: #EDF0F3;
    --bg: #FFFFFF;
    --bg-soft: #F6F8FA;
    --bg-header: rgba(255, 255, 255, 0.82);
    --code-bg: #F2F4F7;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    --measure: 46rem;          /* readable content width */
    --gutter: clamp(1rem, 4vw, 2rem);
}

@media (prefers-color-scheme: dark) {
    :root {
        --roundel-blue: #58A9EE;
        --roundel-blue-hover: #86C2F5;
        --roundel-blue-light: #10263A;
        --accent-ring: rgba(88, 169, 238, 0.45);

        --text: #E7EBEF;
        --text-muted: #9AA5B1;
        --border: #262C33;
        --border-soft: #1E242A;
        --bg: #0C0E11;
        --bg-soft: #14181D;
        --bg-header: rgba(12, 14, 17, 0.82);
        --code-bg: #14181D;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
    }
}

*, *::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 { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-wrap: break-word;
}

/* Keyboard focus is visible everywhere; mouse clicks stay clean. */
:focus-visible {
    outline: 2px solid var(--roundel-blue);
    outline-offset: 2px;
    border-radius: 3px;
}

.container {
    width: 100%;
    max-width: var(--measure);
    margin: 0 auto;
    padding-inline: var(--gutter);
}

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

header.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    background: var(--bg-header);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
}

/* Browsers without backdrop-filter get a solid bar rather than a see-through one. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    header.site-header { background: var(--bg); }
}

header.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

a.site-title {
    font-weight: 700;
    font-size: clamp(1.05rem, 1rem + 0.3vw, 1.3rem);
    letter-spacing: 0.06em;
    color: var(--roundel-blue);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease;
}

a.site-title:hover { color: var(--roundel-blue-hover); }

nav.lang-nav {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1rem);
    font-size: 0.875rem;
    min-width: 0;
}

nav.lang-nav > a {
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease;
}

nav.lang-nav > a:hover { color: var(--roundel-blue); }

/* Home link is the first thing to go when space runs out — the language
   switcher is the one control that must survive on a 320px screen. */
@media (max-width: 26rem) {
    nav.lang-nav > a { display: none; }
}

/* ------------------------------------------------------- language switch  */

/* Flags: real artwork from flag-icons (MIT, (c) 2013 Panayiotis Lipiridis),
   self-hosted under /assets/flags/. Loaded as background images on a
   fixed-size box, so the icon can never resize the layout — a sizeless inline
   <svg> falls back to 300x150 when a stylesheet is missing or stale, which is
   exactly how the header broke once. The box keeps its size regardless.
   Emoji flags are deliberately NOT used: Windows ships no colour flag emoji,
   so they are invisible to a large share of desktop visitors. */
.flag {
    display: inline-block;
    width: 1.3125rem;
    height: 0.9375rem;
    flex: none;
    border-radius: 2px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Hairline ring so white-heavy flags (JP, PL, KR) stay visible on white. */
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14);
}

@media (prefers-color-scheme: dark) {
    .flag { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22); }
}

.flag-tr    { background-image: url(/assets/flags/tr.svg); }
.flag-en    { background-image: url(/assets/flags/en.svg); }
.flag-de    { background-image: url(/assets/flags/de.svg); }
.flag-fr    { background-image: url(/assets/flags/fr.svg); }
.flag-it    { background-image: url(/assets/flags/it.svg); }
.flag-nl    { background-image: url(/assets/flags/nl.svg); }
.flag-es    { background-image: url(/assets/flags/es.svg); }
.flag-pl    { background-image: url(/assets/flags/pl.svg); }
.flag-pt    { background-image: url(/assets/flags/pt.svg); }
.flag-ru    { background-image: url(/assets/flags/ru.svg); }
.flag-ja    { background-image: url(/assets/flags/ja.svg); }
.flag-ko    { background-image: url(/assets/flags/ko.svg); }
.flag-zh-CN { background-image: url(/assets/flags/zh-CN.svg); }
.flag-ar    { background-image: url(/assets/flags/ar.svg); }

details.lang-switch {
    position: relative;
    display: inline-block;
}

details.lang-switch > summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    cursor: pointer;
    user-select: none;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

details.lang-switch > summary::-webkit-details-marker { display: none; }
details.lang-switch > summary::marker { content: ""; }

details.lang-switch > summary::after {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    margin-inline-start: 0.15rem;
    border-right: 1.6px solid currentColor;
    border-bottom: 1.6px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    opacity: 0.55;
    transition: transform 0.18s ease;
}

details.lang-switch[open] > summary::after { transform: translateY(1px) rotate(-135deg); }

details.lang-switch > summary:hover {
    border-color: var(--roundel-blue);
    color: var(--roundel-blue);
    box-shadow: var(--shadow-md);
}

details.lang-switch > ul {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 0.5rem);
    z-index: 60;
    margin: 0;
    padding: 0.375rem;
    list-style: none;
    min-width: 12rem;
    max-height: min(70vh, 26rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

details.lang-switch > ul li { margin: 0; }

details.lang-switch > ul a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
}

details.lang-switch > ul a:hover { background: var(--bg-soft); color: var(--roundel-blue); }

details.lang-switch > ul a.active {
    color: var(--roundel-blue);
    font-weight: 600;
    background: var(--roundel-blue-light);
}

/* On phones the dropdown docks to the screen edges instead of hanging off it. */
@media (max-width: 30rem) {
    details.lang-switch > ul {
        position: fixed;
        inset-inline: var(--gutter);
        top: 3.75rem;
        min-width: 0;
        max-height: min(70vh, 24rem);
    }
}

/* ----------------------------------------------------------------- main   */

main {
    padding-block: clamp(1.75rem, 5vw, 3rem) clamp(3rem, 8vw, 5rem);
}

h1 {
    font-size: clamp(1.75rem, 1.35rem + 1.9vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
    line-height: 1.2;
}

h2 {
    font-size: clamp(1.3rem, 1.12rem + 0.85vw, 1.6rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 2.25rem 0 0.75rem;
    line-height: 1.3;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-soft);
}

/* The first heading after the intro shouldn't carry a divider. */
h1 + h2, p.lead + h2 { border-top: none; padding-top: 0; margin-top: 1.5rem; }

h3 { font-size: 1.15rem; font-weight: 650; margin: 1.75rem 0 0.5rem; line-height: 1.35; }
h4 { font-size: 1.02rem; font-weight: 650; margin: 1.25rem 0 0.5rem; }

/* Anchored headings shouldn't hide under the sticky header. */
h1, h2, h3, h4 { scroll-margin-top: 4.5rem; }

p { margin: 0 0 1rem; }

p.lead {
    font-size: clamp(1.05rem, 1rem + 0.4vw, 1.2rem);
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

a {
    color: var(--roundel-blue);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
    transition: color 0.15s ease;
}

a:hover { color: var(--roundel-blue-hover); }

ul, ol { margin: 0 0 1rem; padding-inline-start: 1.4rem; }
li { margin-bottom: 0.35rem; }
li::marker { color: var(--text-muted); }

strong { font-weight: 650; }

blockquote {
    margin: 1.25rem 0;
    padding: 0.875rem 1.125rem;
    border-inline-start: 3px solid var(--roundel-blue);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--roundel-blue-light);
    color: var(--text);
}

blockquote p:last-child { margin-bottom: 0; }

code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.875em;
    background: var(--code-bg);
    padding: 0.12em 0.4em;
    border-radius: 4px;
}

pre {
    background: var(--code-bg);
    padding: 1rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.55;
    margin: 1.25rem 0;
}

pre code { background: none; padding: 0; }

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

/* ----------------------------------------------------------------- tables */

/* Wide tables scroll inside their own box; the page never scrolls sideways. */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.25rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.9375rem;
}

.table-wrap > table { min-width: 32rem; }

th, td {
    padding: 0.625rem 0.875rem;
    text-align: start;
    vertical-align: top;
    border-bottom: 1px solid var(--border-soft);
}

th {
    background: var(--bg-soft);
    font-weight: 650;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-soft); }

table.locale-list td { padding: 0.75rem 0.875rem; }
table.locale-list td:first-child { font-weight: 600; min-width: 9rem; }

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

.muted-langs {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.9;
    margin-top: 1rem;
}

.muted-langs a { color: var(--text-muted); text-decoration: none; }
.muted-langs a:hover { color: var(--roundel-blue); text-decoration: underline; }

footer.site-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
    padding-block: clamp(1.5rem, 4vw, 2.25rem);
    margin-top: clamp(3rem, 8vw, 4.5rem);
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer.site-footer p { margin: 0 0 0.5rem; }
footer.site-footer a { color: var(--text-muted); text-decoration: none; }
footer.site-footer a:hover { color: var(--roundel-blue); text-decoration: underline; }

/* ------------------------------------------------------------------- RTL  */
/* Logical properties above (padding-inline, inset-inline, text-align: start)
   handle most of RTL on their own; only genuinely directional bits remain. */

html[dir="rtl"] body { text-align: right; }
html[dir="rtl"] blockquote { border-radius: var(--radius) 0 0 var(--radius); }
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3 { letter-spacing: normal; }

/* ----------------------------------------------------------------- print  */

@media print {
    header.site-header, footer.site-footer, nav.lang-nav { display: none; }
    body { font-size: 11pt; color: #000; background: #fff; }
    .container { max-width: none; padding: 0; }
    a { color: #000; text-decoration: underline; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #444; }
    .table-wrap { overflow: visible; border: none; box-shadow: none; }
    h2 { break-after: avoid; }
    table, blockquote, pre { break-inside: avoid; }
}
