/* ============================================================
   ======================  DESKTOP STYLE  ======================
   ============================================================ */

:root {
    --note-font-size: 18px;
    --note-line-height: 1.6;
    --note-figcaption: 14px;
    --note-bg: #ffffff;
    --note-text: #111111;
    --note-link: #0645ad;
    --note-muted: #666666;
    --note-card: #ffffff;
}

:root.theme-dark {
    --note-bg: #0f1115;
    --note-text: #f2f2f2;
    --note-link: #8ab4f8;
    --note-muted: #b5b5b5;
    --note-card: #161a20;
}

body {
    background: var(--note-bg);
    color: var(--note-text);
}

.note-container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
    font-size: var(--note-font-size);
    line-height: var(--note-line-height);
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    background: var(--note-card);
    color: var(--note-text);
}

.note-img-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 9999;
}

.note-img-overlay.open {
    display: flex;
}

.note-img-overlay__inner img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.note-container h2,
.note-container h3 {
    text-align: center;
    margin-top: 40px;
}

.note-container figure {
    text-align: center;
}

.note-container img {
    cursor: zoom-in;
    display: block;
    margin: 20px auto;
    max-width: 80%;
    height: auto;
}

.font-controls {
    display: none;
    justify-content: center;
    gap: 8px;
    margin: 10px 0 6px;
}

.font-controls button {
    padding: 6px 10px;
    border: 1px solid #ccc;
    background: #f6f6f6;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
}

.font-controls button:active {
    background: #e2e2e2;
}

.theme-toggle {
    display: none;
    justify-content: center;
    gap: 8px;
    margin: 6px 0 10px;
}

.theme-toggle button {
    padding: 6px 12px;
    border: 1px solid #ccc;
    background: #f6f6f6;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
}

.theme-toggle button.is-active {
    background: #ddd;
    font-weight: 700;
}

.theme-toggle button:active {
    background: #e2e2e2;
}

.theme-toggle button:focus,
.font-controls button:focus {
    outline: 2px solid #999;
    outline-offset: 2px;
}

.note-container a {
    color: var(--note-link);
}

.note-container figcaption {
    font-size: var(--note-figcaption);
    margin-top: 8px;
    color: var(--note-muted);
}

.note-container ul {
    padding-left: 1.2em;
}

.note-container li {
    margin-bottom: 6px;
    white-space: normal;
}


/* ============================================================
   ===========   MOBILE: custom 2-button menu   ================
   ============================================================ */
@media (max-width: 768px) {

    /* перебиваем inline-style у <ul id="nav"> */
    #nav {
        height: auto !important;
        background: #000 !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between;
        align-items: stretch;
        padding: 0;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
        min-width: 0 !important;
        position: relative;
    }

    /* скрываем ВСЕ пункты меню */
    #nav > li {
        display: none !important;
        float: none !important;
        width: 50% !important;
        margin: 0 !important;
        padding: 0 !important;
        min-width: 0 !important;
        position: relative;
        background: #000 !important;
        border-left: 1px solid #000;
        border-right: 1px solid #000;
        box-sizing: border-box;
    }

    /* показываем только MAP */
    #nav > li.nav-map {
        display: block !important;
    }

    /* показываем только SMALL NOTES */
    #nav > li.nav-notes {
        display: block !important;
    }

    /* кнопки — пополам */
    #nav > li > a {
        flex: 1 1 50%;
        display: block !important;
        text-align: center;
        padding: 12px 0 !important;
        color: #fff !important;
        background: #000 !important;
        background-image: none !important;
        font-size: 15px !important;
        font-weight: bold;
        border-right: 1px solid #555;
        height: auto !important;
        width: 100% !important;
        box-sizing: border-box;
        min-width: 0 !important;
        border-left: 1px solid #000;
    }

    #nav > li.nav-notes > a {
        border-right: none;
        border-left: 1px solid #000;
    }

    /* подменю Small Notes — скрыто по умолчанию */
    #nav > li.nav-notes ul {
        display: none;
        background: #141414;
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
        min-width: 0 !important;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        min-width: 100% !important;
        box-sizing: border-box;
        z-index: 999;
        box-shadow: 0 3px 8px rgba(0,0,0,0.25);
        border-top: 1px solid #555;
    }

    #nav > li.nav-notes ul li {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box;
    }

    #nav > li.nav-notes ul li a {
        display: block;
        width: 100% !important;
        padding: 10px 8px;
        text-align: center;
        font-size: 13px;
        color: white !important;
        border-top: 1px solid #444;
        background: #141414 !important;
        box-sizing: border-box;
        white-space: normal;
        line-height: 1.3;
        text-transform: none;
        height: auto !important;
    }

    .font-controls {
        display: flex;
    }

    .theme-toggle {
        display: flex;
    }

    /* когда открыто */
    #nav > li.nav-notes.open ul {
        display: block !important;
    }

    html, body {
        max-width: 100%;
        overflow-x: hidden;
        margin: 0;
        padding: 0;
        min-width: 0 !important;
    }

    :root {
        --note-font-size: clamp(19px, 4.5vw, 21px);
        --note-line-height: 1.65;
        --note-figcaption: clamp(15px, 3.3vw, 16px);
    }

    .note-container {
        margin: 20px auto;
        padding: 0 14px;
        font-size: var(--note-font-size);
        line-height: var(--note-line-height);
        max-width: 100%;
        box-sizing: border-box;
    }

    .note-container img {
        max-width: 100%;
        height: auto;
        cursor: zoom-in;
        margin: 16px auto;
    }

    .note-container figcaption {
        font-size: clamp(15px, 3.3vw, 16px);
    }

    /* перестраховка, если где-то остались float/width */
    #container, #nav {
        overflow: visible !important;
        min-width: 0 !important;
        position: relative;
    }

    /* скрываем выбор версии на мобильном */
    .version-switch,
    #radio {
        display: none !important;
    }
}
