/* ==========================================================
   ШРИФТ
   ========================================================== */
@font-face {
    font-family: 'aboba';
    src: url('ui/fsb.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* ----- ПЕРЕМЕННЫЕ ----- */
:root {
    --border-color: #271F2A;
    --text-color: #0A0809;
    --bg-start: #B8B8B8;
    --bg-end: #E4E1DA;
    --link-hover: rgba(89, 33, 24, 0.1);
    --font-main: 'aboba', sans-serif;
    --left-width: 120px;
    --right-width: 120px;
    --col-height: 450px;
}

/* ----- ГЛОБАЛЬНЫЙ СБРОС ----- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ----- BODY ----- */
body {
    background-image: url('ui/bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    image-rendering: crisp-edges;
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    margin: 0;
    border: 7px groove var(--border-color);
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ----- КОНТЕЙНЕР .hoy ----- */
.hoy {
    display: flex;
    flex-wrap: nowrap;
    justify-content: left;
    align-items: stretch;
    gap: 8px;
    max-width: 100%;
    overflow-x: auto;
    padding: 5px 0;
}

.hoy > div {
    white-space: normal;
    word-wrap: break-word;
}

/* ----- ЛЕВАЯ КОЛОНКА (lf) ----- */
#lf {
    flex: 1 1 var(--left-width);
    min-width: var(--left-width);
    max-width: var(--left-width);
    height: var(--col-height);
    min-height: var(--col-height);
    max-height: var(--col-height);
    padding: 8px 4px;
    background: linear-gradient(to top, var(--bg-start), var(--bg-end));
    border: 5px ridge var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ----- ПРАВАЯ КОЛОНКА (rf) ----- */
#rf {
    flex: 1 1 var(--right-width);
    min-width: var(--right-width);
    max-width: var(--right-width);
    height: var(--col-height);
    min-height: var(--col-height);
    max-height: var(--col-height);
    padding: 8px 4px;
    background: linear-gradient(to top, var(--bg-start), var(--bg-end));
    border: 5px ridge var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ----- СРЕДНЯЯ КОЛОНКА (frame1) ----- */
#frame1 {
    flex: 1 1 auto;
    min-width: 500px;
    height: var(--col-height);
    min-height: var(--col-height);
    max-height: var(--col-height);
    padding: 15px 20px;
    background: linear-gradient(to top, var(--bg-start), var(--bg-end));
    border: 7px ridge var(--border-color);
    overflow-y: auto;
}

/* ----- НАВИГАЦИЯ (внутри #lf) ----- */
#nav-container p {
    margin: 0;
    padding: 0;
}

#nav-container a {
    display: block;
    padding: 6px 4px;
    margin: 4px 0;
    color: var(--text-color);
    text-decoration: underline dashed var(--border-color);
    font-size: 14px;
    transition: 0.2s;
    border-left: 3px solid transparent;
}

#nav-container a:hover {
    background: var(--link-hover);
    padding-left: 12px;
    border-left-color: var(--border-color);
}

/* ----- GIF-ИЗОБРАЖЕНИЯ (внутри #rf) ----- */
#gif-container img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 6px auto;
    border: 3px dashed var(--border-color);
    border-radius: 0.5px;
    transition: transform 0.2s, box-shadow 0.2s;
}

#gif-container img:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* ----- ОБЩИЕ ИЗОБРАЖЕНИЯ ----- */
img {
    max-width: 100%;
    height: auto;
}

/* ----- ССЫЛКИ ----- */
a:link {
    color: var(--text-color);
    text-decoration: none;
}
a:visited {
    color: var(--text-color);
}
a:active {
    outline: none;
}
a:focus-visible {
    outline: 3px dashed var(--border-color);
    outline-offset: 2px;
}

/* ----- ТИПОГРАФИКА ----- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-main);
    font-weight: 600;
    margin: 0.6rem 0 0.4rem;
    line-height: 1.2;
}
h1 { font-size: 2.2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; }

p, ul, ol, blockquote {
    margin: 0 0 0.8rem 0;
}
ul, ol {
    padding-left: 1.5rem;
}

/* ----- СКРОЛЛБАР ----- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-start);
    border-radius: 1px;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 0.5px;
    border: 2px double var(--bg-end);
}
::-webkit-scrollbar-thumb:hover {
    background: #271F2A;
}

/* ==========================================================
   АДАПТИВНОСТЬ
   ========================================================== */
@media (max-width: 768px) {
    .hoy {
        flex-wrap: wrap;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    #lf, #rf, #frame1 {
        flex: 1 1 auto;
        width: 100%;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        max-width: 100% !important;
        min-width: 0 !important;
        border-width: 4px;
    }
    #lf, #rf {
        border-width: 4px;
        padding: 8px;
    }
    #frame1 {
        border-width: 5px;
        padding: 12px;
    }
    body {
        border-width: 4px;
        padding: 5px;
    }
}

@media (max-width: 400px) {
    #nav-container a {
        font-size: 13px;
        padding: 5px 4px;
    }
    #gif-container img {
        border-width: 2px;
    }
}

/* ----- CANVAS (для g.html) ----- */
#controls button {
    font-family: var(--font-main);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer;
    color: #fff;
    font-weight: 600;
    transition: 0.2s;
    margin: 2px;
}
#controls button:hover {
    transform: scale(1.05);
    filter: brightness(1.2);
}

#myCanvas {
    background: white;
    border: 2px groove var(--border-color);
    margin: 20px auto;
    display: block;
    width: 100%;
    max-width: 600px;
    height: auto;
    touch-action: none;
}

/* ----- ПАЗЛ (если используется) ----- */
.tile {
    width: 100%;
    aspect-ratio: 1/1;
    background: var(--border-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s;
    border-radius: 3px;
}
.empty-tile {
    background: white;
}