/* ==========================================================================
   Домъ·ОС — режим рабочего стола в духе настольных систем середины 90-х.
   Все правила под html.os / html.os-ready: без JS файл ничего не меняет.
   ========================================================================== */

:root { --taskbar-h: 34px; }

/* ---------- Загрузка: чёрный экран, знак Дома, полоска из квадратиков ---------- */
html.os:not(.booted) body { overflow: hidden; }
html.os:not(.booted) .boot {
    display: grid; place-items: center; align-content: center; gap: 28px;
    position: fixed; inset: 0; z-index: 1000; background: #000; color: #FFF;
}
html.os.booted .boot { display: none; }
.boot-brand { display: flex; align-items: center; gap: 22px; padding: 0 16px; }
.boot-seal { width: 128px; height: 128px; flex: none; image-rendering: pixelated; }
.boot-brand b { display: block; font: 700 clamp(2.4rem, 9vw, 4rem)/1 var(--f-ui); letter-spacing: -.02em; }
.boot-brand span { display: block; margin-top: 8px; font: 400 clamp(.85rem, 3vw, 1.05rem)/1.3 var(--f-ui); color: #C0C0C0; }
.boot-gauge { width: min(80vw, 320px); height: 22px; padding: 3px; background: #000; box-shadow: inset -1px -1px #FFF, inset 1px 1px #808080; }
.boot-gauge span {
    display: block; height: 100%; width: 0;
    background: repeating-linear-gradient(90deg, #0000AA 0 12px, transparent 12px 15px);
    animation: gauge 1.4s .2s steps(20, end) forwards;
}
@keyframes gauge { to { width: 100%; } }
.boot-log { list-style: none; margin: 0; padding: 0; min-height: 7.2em; width: min(88vw, 320px); font: 400 .85rem/1.6 var(--f-mono); color: #A0A0A0; }
.boot-log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.boot-log li::before { content: "> "; }
@media (max-width: 480px) { .boot-brand { flex-direction: column; text-align: center; gap: 14px; } .boot-seal { width: 96px; height: 96px; } }
html.os.booting-out .boot { opacity: 0; }

/* До готовности ОС контент не показываем, чтобы не мелькал документ */
html.os:not(.os-ready) .desk, html.os:not(.os-ready) .site-foot, html.os:not(.os-ready) .site-head { visibility: hidden; }

/* ---------- Стол ---------- */
html.os-ready body { overflow: hidden; height: 100dvh; font-size: 14px; }
html.os-ready .site-head, html.os-ready .site-foot { display: none; }
html.os-ready .desk {
    position: fixed; inset: 0 0 var(--taskbar-h) 0; overflow: hidden; isolation: isolate;
    max-width: none; margin: 0; background: var(--desk); box-shadow: none;
}
/* печать Дома в углу стола — как фирменные обои */
html.os-ready .desk::before {
    content: ""; position: absolute; z-index: -1; right: 4vw; bottom: 5vh;
    width: 256px; aspect-ratio: 1;
    background: url("../assets/logo/pixel-mark-64.svg") center / contain no-repeat;
    image-rendering: pixelated; opacity: .9; pointer-events: none;
}
html.os-ready .skip-hint { display: block; position: absolute; left: 12px; bottom: 8px; margin: 0; font: .8rem var(--f-ui); color: #FFF; }
html.os-ready .skip-hint a { color: #FFF; }

/* ---------- Значки ---------- */
.icons {
    position: absolute; top: 10px; left: 8px; bottom: 30px;
    display: grid; grid-auto-flow: column;
    grid-template-rows: repeat(auto-fill, 96px); grid-auto-columns: 100px;
    gap: 4px 6px; margin: 0; padding: 0; list-style: none;
}
.icon {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 100%; height: 100%; padding: 4px 2px; background: none; border: 0;
    color: #FFF; cursor: pointer; font: inherit;
}
.icon-art { width: 48px; height: 48px; display: grid; place-items: center; }
.icon-art img, .icon-art svg { width: 48px; height: 48px; }
.icon-label { max-width: 100%; padding: 1px 3px; font: 400 .82rem/1.2 var(--f-ui); text-align: center; overflow-wrap: break-word; }
.icon:focus-visible { outline: none; }
.icon:focus-visible .icon-label { background: var(--sel); color: var(--sel-ink); outline: 1px dotted #FFF; }
.icon:focus-visible .icon-art, .icon:active .icon-art { filter: brightness(.6) sepia(1) hue-rotate(190deg) saturate(4); }

/* ---------- Окна ---------- */
html.os-ready .win {
    position: absolute; display: none; flex-direction: column;
    min-width: 300px; min-height: 180px; max-width: 100%; max-height: 100%;
    margin: 0; padding: 3px; border: 0;
    background: var(--face); box-shadow: var(--raised);
    resize: both; overflow: hidden;
}
html.os-ready .win.is-open { display: flex; }
html.os-ready .win.is-max { inset: 0 !important; width: auto !important; height: auto !important; resize: none; }
html.os-ready .win.is-opening { animation: win-open .18s steps(3, end); }
@keyframes win-open { from { clip-path: inset(0 100% 100% 0); } to { clip-path: inset(0 0 0 0); } }
html.os-ready .win.is-closing { animation: win-close .14s steps(3, end) forwards; pointer-events: none; }
@keyframes win-close { to { clip-path: inset(0 100% 100% 0); } }

.win-bar {
    display: none; flex: none; align-items: center; gap: 4px; height: 22px; padding: 0 2px 0 3px;
    background: var(--title-off); color: #DCDCDC; user-select: none; touch-action: none;
}
html.os-ready .win-bar { display: flex; }
.win.is-focused .win-bar { background: var(--title); color: var(--title-ink); }
.win-icon { flex: none; width: 16px; height: 16px; display: grid; place-items: center; }
.win-icon img, .win-icon svg { width: 16px; height: 16px; }
.win-title { flex: 1; min-width: 0; margin: 0; font: 700 .82rem/1 var(--f-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-btns { display: flex; gap: 0; }
.win-btn {
    width: 18px; height: 16px; padding: 0; display: grid; place-items: center; margin-left: 2px;
    font: 700 11px/1 var(--f-ui); color: #000; background: var(--face); border: 0; box-shadow: var(--raised); cursor: pointer;
}
:root[data-theme="dark"] .win-btn { color: var(--ink); }
.win-btn:active { box-shadow: var(--pressed); }
.win-btn[data-cmd="close"] { margin-left: 4px; }
.win-btn span { transform: translateY(-1px); }

.win-body {
    flex: 1; min-height: 0; margin-top: 3px; overflow: auto; overscroll-behavior: contain;
    padding: 16px clamp(12px, 3vw, 24px) 22px;
    background: var(--well); box-shadow: var(--sunken);
    scrollbar-color: var(--face) var(--face-2);
}
.win-body > :first-child { margin-top: 0; }

/* «О Домѣ»: окно приветствия */
html.os-ready #about .win-body { padding: 0; background: var(--face); }
html.os-ready #about .hero-in { min-height: 220px; grid-template-columns: 44px minmax(0, 1fr) auto; }
html.os-ready #about .hero-in::before { font-size: 1.1rem; }
html.os-ready #about .hero h1 { font-size: clamp(1.4rem, 3.6cqi, 2rem); }
html.os-ready #about .hero-emblem { width: 160px; height: 160px; }
html.os-ready #about .about-text { padding: 16px 20px 22px; background: var(--well); box-shadow: var(--sunken); margin: 0 6px 6px; }
@container (max-width: 560px) {
    html.os-ready #about .hero-in { grid-template-columns: 26px minmax(0, 1fr); }
    html.os-ready #about .hero-emblem { grid-column: 2; order: -1; width: 96px; height: 96px; margin-top: 12px; }
}

/* ---------- Папки: проводник с крупными значками ---------- */
html.os-ready .folder .win-body { background: var(--well); }
.folder-path {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0; margin: -6px -8px 14px; padding: 3px 6px;
    font: .85rem var(--f-ui); background: var(--face); box-shadow: var(--sunken-soft);
}
.folder-path::before { content: "Адрес:"; margin-right: 8px; color: var(--ink-3); }
.folder-path span + span::before { content: "\\"; margin: 0 2px; }
.folder .group-head h2 { font-size: 1.15rem; margin: 0 0 .3em; }
.folder .group-head p { font-size: .9rem; }
.folder-items { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.folder-item {
    display: flex; align-items: center; gap: 10px; width: 100%; height: 100%; padding: 6px 8px;
    text-align: left; cursor: pointer; color: var(--ink); font: inherit; background: none; border: 0;
}
.folder-item:hover .folder-item-text b, .folder-item:focus-visible .folder-item-text b { background: var(--sel); color: var(--sel-ink); }
.folder-item:focus-visible { outline: 1px dotted var(--ink); outline-offset: -2px; }
.folder-item-art { flex: none; width: 48px; height: 48px; display: grid; place-items: center; }
.folder-item-art img, .folder-item-art svg { width: 48px; height: 48px; }
.folder-item-text b { display: inline; padding: 0 2px; font: 700 .95rem/1.3 var(--f-ui); }
.folder-item-text small { display: block; margin-top: 2px; font-size: .8rem; color: var(--ink-3); line-height: 1.3; }
.folder-status { margin: 14px -8px -12px; padding: 2px 6px; font: .8rem var(--f-ui); color: var(--ink-2); background: var(--face); box-shadow: var(--sunken-soft); }

/* ---------- Вѣдомости ---------- */
html.os-ready #blog .post-card { cursor: pointer; }
html.os-ready .reader .article-head h1 { font-size: 1.5rem; }
.reader-foot { margin: 22px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); }

/* ---------- Панель задач ---------- */
.taskbar { display: none; }
html.os-ready .taskbar {
    display: flex; align-items: center; gap: 4px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    height: var(--taskbar-h); padding: 2px 2px calc(2px + env(safe-area-inset-bottom));
    background: var(--face); box-shadow: inset 0 1px var(--lite), inset 0 2px var(--hi);
}
.start-btn {
    display: flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px 0 4px; flex: none;
    font: 700 .9rem/1 var(--f-ui); color: var(--ink); background: var(--face); border: 0; box-shadow: var(--raised); cursor: pointer;
}
.start-btn img { width: 16px; height: 16px; image-rendering: pixelated; }
.start-btn[aria-expanded="true"] { box-shadow: var(--pressed); }
.tasks { display: flex; gap: 3px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding-left: 4px; }
.task {
    flex: 0 1 160px; min-width: 36px; height: 26px; padding: 0 6px;
    display: flex; align-items: center; gap: 5px;
    font: 400 .82rem/1 var(--f-ui); color: var(--ink); background: var(--face); border: 0; box-shadow: var(--raised); cursor: pointer;
    white-space: nowrap; overflow: hidden;
}
.task img, .task svg { width: 16px; height: 16px; flex: none; }
.task span { overflow: hidden; text-overflow: ellipsis; }
.task.is-active {
    font-weight: 700; box-shadow: var(--pressed);
    background: repeating-conic-gradient(var(--face) 0 25%, var(--hi) 0 50%) 0 0 / 2px 2px;
}
.tray { display: flex; align-items: center; gap: 2px; flex: none; height: 26px; padding: 0 6px 0 4px; box-shadow: var(--sunken-soft); }
.tray-btn { height: 20px; min-width: 22px; padding: 0 4px; font: 700 .9rem/1 var(--f-ui); color: var(--ink); background: none; border: 0; cursor: pointer; }
.tray-btn:hover { box-shadow: var(--raised-soft); }
.tray-btn[aria-pressed="true"] { box-shadow: var(--sunken-soft); }
.clock { display: flex; align-items: center; padding-left: 6px; }
.dial { display: none; }
.clock-text { font: .82rem var(--f-ui); white-space: nowrap; }
.clock-text b { font-weight: 400; }
.clock-text span { display: none; }

/* ---------- Меню «Пуск» ---------- */
.start-menu {
    position: fixed; left: 2px; bottom: calc(var(--taskbar-h) - 2px); z-index: 950;
    display: flex; width: min(300px, calc(100vw - 4px)); max-height: calc(100dvh - var(--taskbar-h)); overflow: auto;
    padding: 3px; background: var(--face); color: var(--ink); box-shadow: var(--raised);
}
.start-menu[hidden] { display: none; }
/* синяя полоса слева с названием */
.start-head { flex: none; width: 26px; display: flex; align-items: flex-end; background: var(--title); color: var(--title-ink); }
.start-head img { display: none; }
.start-head div { writing-mode: vertical-rl; transform: rotate(180deg); padding: 8px 0; white-space: nowrap; }
.start-head b { font: 700 1.05rem/1 var(--f-ui); }
.start-head small { display: none; }
.start-list { flex: 1; list-style: none; margin: 0; padding: 0; min-width: 0; }
.start-list hr { margin: 3px 2px; }
.start-list .is-nested { padding-left: 18px; }
.start-item {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px 5px 6px;
    font: 400 .88rem/1.2 var(--f-ui); color: var(--ink); text-align: left; background: none; border: 0; cursor: pointer;
}
.start-item:hover, .start-item:focus-visible { background: var(--sel); color: var(--sel-ink); outline: none; }
.start-item img, .start-item svg { width: 32px; height: 32px; flex: none; }
.start-list .is-nested .start-item img, .start-list .is-nested .start-item svg { width: 20px; height: 20px; }
.start-item small { display: block; font-size: .75rem; opacity: .8; }
.start-foot { display: none; }

/* ---------- Телефон ---------- */
@media (max-width: 760px) {
    :root { --taskbar-h: 44px; }
    .icons {
        inset: 0; padding: 14px 8px 60px;
        grid-auto-flow: row; grid-template-rows: none;
        grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: auto;
        gap: 14px 4px; align-content: start; overflow-y: auto;
    }
    .icon-art, .icon-art img, .icon-art svg { width: 56px; height: 56px; }
    .icon-label { font-size: .85rem; }
    html.os-ready .desk::before { right: 50%; bottom: 12%; transform: translateX(50%); width: 192px; opacity: .6; }
    html.os-ready .win { inset: 0 !important; width: auto !important; height: auto !important; resize: none; }
    .win-bar { height: 32px; }
    .win-title { font-size: .95rem; }
    .win-btn[data-cmd="min"], .win-btn[data-cmd="max"] { display: none; }
    .win-btn { width: 30px; height: 26px; font-size: 15px; }
    .start-btn, .task { height: 36px; }
    .tray { height: 36px; }
    .tasks .task { flex-basis: 40px; }
    .tasks .task span { display: none; }
    .folder-items { grid-template-columns: 1fr; }
    html.os-ready .skip-hint { left: 10px; right: 10px; bottom: 8px; text-align: center; }
}

/* в ночной схеме тёмные детали картинок-значков не сливаются с фоном */
:root[data-theme="dark"] :is(.folder-item-art, .icon-art, .cameo, .try-card) img { filter: drop-shadow(0 0 1px #FFF); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.folder-item-art, .icon-art, .cameo, .try-card) img { filter: drop-shadow(0 0 1px #FFF); } }

/* ---------- Окно игры — по размеру поля ---------- */
html.os-ready .win[data-fit] { width: auto !important; height: auto !important; min-width: 0; min-height: 0; resize: none; }
html.os-ready .win[data-fit] .win-body { padding: 8px; background: var(--face); box-shadow: none; overflow: visible; container-type: normal; }
html.os-ready .win[data-fit] [data-cmd="max"] { visibility: hidden; }
@media (max-width: 760px) {
    html.os-ready .win[data-fit] { inset: 0 !important; }
    html.os-ready .win[data-fit] .win-body { overflow: auto; }
}

/* ---------- Веб-сервисы: окно-браузер с настоящим сайтом ---------- */
html.os-ready .win.webview > .win-body { display: none; }
.browser { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.browser-bar { flex: none; display: flex; align-items: center; gap: 4px; padding: 2px; }
.browser-btn {
    flex: none; height: 24px; min-width: 26px; padding: 0 8px;
    font: 400 .82rem/1 var(--f-ui); color: var(--ink); background: var(--face);
    border: 0; box-shadow: var(--raised); cursor: pointer; white-space: nowrap;
}
.browser-btn:active { box-shadow: var(--pressed); }
.browser-btn:focus-visible { outline: 1px dotted var(--ink); outline-offset: -4px; }
.browser-open { font-weight: 700; }
.browser-label { flex: none; font: .82rem var(--f-ui); color: var(--ink); }
.browser-addr {
    flex: 1; min-width: 0; height: 24px; padding: 0 6px; display: flex; align-items: center;
    font: .82rem var(--f-mono); color: var(--ink); text-decoration: none;
    background: var(--well); box-shadow: var(--sunken);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.browser-view { flex: 1; min-height: 0; padding: 2px; background: var(--well); box-shadow: var(--sunken); }
.browser-view iframe { display: block; width: 100%; height: 100%; border: 0; background: #FFF; }
.browser-status { flex: none; margin: 0; padding: 2px 6px; font: .78rem var(--f-ui); color: var(--ink); box-shadow: var(--sunken-soft); }
/* при перетаскивании и изменении размера фрейм не должен перехватывать мышь */
html.os-ready .win.is-dragging .browser-view iframe { pointer-events: none; }
@media (max-width: 760px) {
    .browser-label { display: none; }
}

/* ---------- «Подробнее о программе» внутри окна ---------- */
.win-page { display: none; }
html.os-ready .win.is-paged > .win-body { display: none; }
html.os-ready .win.is-paged > .win-page { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.page-bar { flex: none; display: flex; align-items: center; gap: 4px; padding: 2px; }
.page-path {
    flex: 1; min-width: 0; height: 24px; display: flex; align-items: center; padding: 0 6px;
    font: .82rem var(--f-ui); color: var(--ink); background: var(--well); box-shadow: var(--sunken);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-open { display: inline-flex; align-items: center; text-decoration: none; }
.page-open:visited { color: var(--ink); }
.win-page-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 14px clamp(10px, 2.5vw, 20px) 20px; background: var(--well); box-shadow: var(--sunken); }
.win-page-body:focus { outline: none; }
.win-page-body .page-sheet.in-window { max-width: none; margin: 0; padding: 0; background: none; box-shadow: none; }
@media (max-width: 760px) { .page-open { display: none; } }
