/* --- the Guide window: a global floating window, sized to its content --- */
#winHelp {
    position: fixed;
    z-index: 1100;
    left: 0; top: 0;                 /* JS centres it on open */
    width: min(600px, 92vw);
    height: min(668px, 88vh);        /* fixed — the two pages do NOT resize it */
}
.win--hidden { display: none !important; }

/* --- Settings window: a macOS-System-Settings-style sidebar + one pane at a time --- */
#winSettings {
    position: fixed;
    z-index: 1100;
    left: 0; top: 0;              /* JS centres it on open */
    width: min(560px, 92vw);
    height: min(430px, 74vh);     /* short — only one section shows at a time */
}
.win-body--settings { overflow: hidden; }   /* the sidebar and the pane scroll on their own instead */
.settings {
    display: flex;
    height: 100%;
    font-family: var(--font-sans);
    color: var(--text-secondary);
}

/* left: the section list */
.set-nav {
    flex-shrink: 0;
    width: 9.5rem;   /* rem, not px — grows with Accessibility → Zoom so labels never clip */
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.75rem 0.55rem;
    overflow-y: auto;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
}
.set-nav-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.5rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 550;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.set-nav-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.set-nav-item.is-active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.set-nav-ico { flex-shrink: 0; width: 1.125rem; height: 1.125rem; display: grid; place-items: center; }
.set-nav-ico svg { width: 1rem; height: 1rem; }

/* right: the section currently selected on the left */
.set-panes {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 1.3rem 1.5rem;
}
.set-pane { display: none; }
.set-pane.is-active { display: block; }
.set-pane-hint { margin: 0 0 0.9rem; font-size: 0.82rem; }
/* section heading repeated inside the pane — hidden on desktop (the nav
   item already names the section); shown when phones fall back to one
   long scrolling list, see the ≤900px rules in css/responsive.css */
.set-pane-title { display: none; }

/* a pane that groups several settings (e.g. Appearance: Theme + Colour +
   Wallpaper; Units: Clock + Temperature) stacks them as labelled blocks */
.set-block + .set-block { margin-top: 1.4rem; padding-top: 1.3rem; border-top: 1px solid var(--border-color); }
.set-block-title { margin: 0 0 0.15rem; font-size: 0.88rem; font-weight: 650; color: var(--text-primary); }

.set-themes { display: flex; gap: 0.85rem; }
.set-theme {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.5rem 0.5rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.set-theme:hover { transform: translateY(-1px); }
.set-theme.is-active {
    border-color: var(--text-primary);
}
.set-theme-pv {
    height: 62px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 9px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    overflow: hidden;
}
.set-theme-pv i { display: block; height: 7px; border-radius: 3px; }
.set-theme-pv i:first-child { width: 70%; }
.set-theme-pv i:last-child  { width: 45%; }
.set-theme-pv--light { background: #ffffff; }
.set-theme-pv--light i { background: #c9ccd2; }
.set-theme-pv--dark { background: #161616; }
.set-theme-pv--dark i { background: #4a4d55; }
.set-theme-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

/* every option button in every pane mirrors .set-theme: [preview] + [name] */
.set-langs, .set-opts { display: flex; gap: 0.5rem; }
.set-lang, .set-opt {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem 0.4rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.1s ease;
}
.set-lang:hover, .set-opt:hover { transform: translateY(-1px); }
.set-lang.is-active, .set-opt.is-active { border-color: var(--text-primary); }
.set-lang-name, .set-opt-name {
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    text-align: center;
}

/* the little preview tile inside each option button */
.set-pv {
    height: 40px;
    border-radius: 7px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* language — a representative glyph */
.pv-lang { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.pv-lang--serif { font-family: 'Newsreader', Georgia, serif; font-style: italic; }

/* wallpaper — the real pattern, at thumbnail scale */
.set-pv--wp[data-pv="grid"] {
    background:
        linear-gradient(var(--pv-ink) 1px, transparent 1px) 0 0 / 8px 8px,
        linear-gradient(90deg, var(--pv-ink) 1px, transparent 1px) 0 0 / 8px 8px,
        var(--bg-primary);
}
.set-pv--wp[data-pv="dots"] {
    background:
        radial-gradient(var(--pv-ink) 1.4px, transparent 1.6px) 0 0 / 9px 9px,
        var(--bg-primary);
}
.set-pv--wp[data-pv="iso"] {
    background:
        repeating-linear-gradient(30deg,  var(--pv-ink) 0 1px, transparent 1px 11px),
        repeating-linear-gradient(150deg, var(--pv-ink) 0 1px, transparent 1px 11px),
        repeating-linear-gradient(90deg,  var(--pv-ink) 0 1px, transparent 1px 11px),
        var(--bg-primary);
}
.set-pv--wp[data-pv="glow"] {
    background:
        radial-gradient(85% 100% at 18% 0%,
            color-mix(in srgb, var(--accent) 34%, transparent) 0%,
            color-mix(in srgb, var(--accent) 12%, transparent) 48%,
            transparent 82%),
        var(--bg-primary);
}

/* motion — a moving ball trailing speed-lines vs. the same ball at rest */
.pv-move { width: 22px; height: 22px; }
.set-opt[data-val="full"] .pv-move { color: var(--accent); }
.set-opt[data-val="reduced"] .pv-move { color: var(--text-secondary); }

/* zoom — the letter "A" shown at the actual relative size of each level */
.pv-zoom { font-weight: 700; color: var(--text-primary); line-height: 1; }

/* font style — each swatch renders "Aa" in its own real typeface */
.pv-font { font-size: 1.05rem; color: var(--text-primary); line-height: 1; }

/* clock — plain digits, no extra chip behind them */
.pv-clock {
    font-family: 'Fira Code', monospace;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}

/* temperature — plain digits, coloured cool for °C / warm for °F */
.pv-temp {
    font-family: 'Fira Code', monospace;
    font-size: 0.92rem;
    font-weight: 700;
}
.set-opt[data-val="c"] .pv-temp { color: #2f7cc4; }
.set-opt[data-val="f"] .pv-temp { color: #d76b2f; }
[data-theme="dark"] .set-opt[data-val="c"] .pv-temp { color: #6cb6ff; }
[data-theme="dark"] .set-opt[data-val="f"] .pv-temp { color: #f2a34d; }

/* accent-colour swatches */
.set-accents { display: flex; gap: 0.7rem; }
.set-accent {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: transform 0.12s ease;
}
.set-accent:hover { transform: scale(1.1); }
.set-accent.is-active { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.set-accent[data-val="green"]  { background: #26d07c; }
.set-accent[data-val="blue"]   { background: #5b9bff; }
.set-accent[data-val="indigo"] { background: #818cf8; }
.set-accent[data-val="purple"] { background: #b794f6; }
.set-accent[data-val="pink"]   { background: #ff7ab8; }
.set-accent[data-val="amber"]  { background: #f2a34d; }
.set-accent[data-val="teal"]   { background: #2dd4bf; }

/* reset button */
.set-reset-note {
    margin: 0 0 0.6rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.set-reset {
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: transparent;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.set-reset:hover, .set-reset.is-armed { color: #e5534b; border-color: #e5534b; }

/* the body fills the fixed height and scrolls if a page runs slightly long */
.win--guide .win-body { overflow-y: auto; }
.guide {
    font-family: var(--font-sans);
    padding: 1.4rem 1.6rem 0;
    color: var(--text-secondary);
    /* column layout so the pager can be pinned to the bottom of the window */
    display: flex;
    flex-direction: column;
    min-height: 100%;
}
.guide-lead {
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-primary);
    margin-bottom: 1.3rem;
}
.guide-card {
    display: flex;
    gap: 1.1rem;
    align-items: flex-start;
    padding: 0.7rem 0;
}
.guide-card + .guide-card { margin-top: 0.35rem; }
.guide-viz {
    flex-shrink: 0;
    width: 108px;
    height: 74px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}
.guide-txt { font-size: 0.86rem; line-height: 1.5; }
.guide-txt b { color: var(--text-primary); display: block; margin-bottom: 0.3rem; font-size: 0.92rem; }
.guide-txt p { margin: 0; }
.guide-txt code {
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
    color: var(--accent);
}
.guide-list { list-style: none; padding: 0; margin: 0.2rem 0 0; display: grid; gap: 0.3rem; }
.guide-list li { display: flex; align-items: center; gap: 0.5rem; }

/* --- two-page booklet: pager + pages --- */
.guide-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    /* pinned to the foot of the window: short pages push it down, long pages
       let it ride along as a sticky footer — same spot on page 1 and page 2 */
    margin-top: auto;
    position: sticky;
    bottom: 0;
    margin-left: -1.6rem;
    margin-right: -1.6rem;
    padding: 0.95rem 1.6rem 1.4rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}
.guide-arrow {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}
.guide-arrow svg { width: 15px; height: 15px; }
.guide-arrow:hover:not(:disabled) { background: var(--bg-tertiary); }
.guide-arrow:disabled { opacity: 0.28; cursor: default; }
.guide-pager-label {
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 3.5ch;
    text-align: center;
}
.guide-page { display: none; }
.guide[data-active="1"] .guide-page[data-page="1"],
.guide[data-active="2"] .guide-page[data-page="2"] { display: block; }

.guide-note {
    margin-top: 1.1rem;
    padding: 0.8rem 0.95rem;
    border-radius: 9px;
    background: var(--bg-secondary);
    font-size: 0.82rem;
    line-height: 1.55;
}
.guide-note b { color: var(--text-primary); }
.guide-note code { font-family: 'Fira Code', monospace; font-size: 0.85em; color: var(--accent); }

/* mini terminal mock (page 1) */
.guide-viz--term .mini-term {
    position: absolute;
    inset: 12px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    border-radius: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 7px 8px;
    font-family: 'Fira Code', monospace;
    font-size: 9px;
    line-height: 1.5;
    color: var(--text-secondary);
    overflow: hidden;
}
.guide-viz--term .mt-line { white-space: nowrap; }
.guide-viz--term .mt-p { color: var(--accent); }
.guide-viz--term .mt-cur {
    display: inline-block;
    width: 4px;
    height: 8px;
    background: var(--accent);
    vertical-align: -1px;
    animation: blink 1s steps(1) infinite;
}

/* traffic-light dots in their real colours */
.tl { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.tl.inl { width: 9px; height: 9px; }
.tl-r { background: #ff5f56; }
.tl-y { background: #ffbd2e; }
.tl-g { background: #27c93f; }

/* mini mock windows inside the viz boxes */
.mini-win {
    position: absolute;
    left: 14px; top: 14px;
    width: 66px; height: 46px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}
.mini-bar {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 12px;
    padding: 0 5px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}
.mini-bar .tl { width: 5px; height: 5px; }

.guide-viz--lights .mini-win { animation: gzMax 4.2s ease-in-out infinite; }
@keyframes gzMax {
    0%, 40% { left: 14px; top: 14px; width: 66px; height: 46px; }
    55%, 85% { left: 5px; top: 5px; width: 94px; height: 62px; }
    100% { left: 14px; top: 14px; width: 66px; height: 46px; }
}

/* move-and-resize: the window slides, then its corner stretches out */
.guide-viz--drag .mini-win--move { animation: gzMoveResize 4.4s ease-in-out infinite; }
.mini-grip {
    position: absolute;
    right: 2px; bottom: 2px;
    width: 7px; height: 7px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    opacity: 0.7;
}
@keyframes gzMoveResize {
    0%, 12%   { transform: translate(0, 0); width: 66px; height: 46px; }
    32%, 46%  { transform: translate(24px, 16px); width: 66px; height: 46px; }
    66%, 84%  { transform: translate(24px, 16px); width: 84px; height: 56px; }
    100%      { transform: translate(0, 0); width: 66px; height: 46px; }
}

.mini-nav {
    position: absolute;
    left: 10px; right: 10px; top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    color: var(--text-secondary);
}
.mini-nav i { font-style: normal; }
.mini-url {
    flex: 1;
    height: 15px;
    display: flex;
    align-items: center;
    padding: 0 5px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    overflow: hidden;
    white-space: nowrap;
    font-size: 9px;
    color: var(--text-primary);
}
.mini-type::after {
    content: "about.cpp";
    display: inline-block;
    max-width: 0;
    overflow: hidden;
    vertical-align: bottom;
    animation: gzType 4s steps(9) infinite;
}
@keyframes gzType {
    0% { max-width: 0; }
    45%, 70% { max-width: 6em; }
    85%, 100% { max-width: 0; }
}
.mini-caret {
    width: 1px;
    height: 9px;
    background: var(--accent);
    margin-left: 1px;
    animation: blink 1s steps(1) infinite;
}

.mini-editor {
    position: absolute;
    inset: 14px;
    display: flex;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.mini-side {
    width: 34px;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
    animation: gzSide 3.4s ease-in-out infinite;
}
.mini-main { flex: 1; background: var(--bg-card); }
@keyframes gzSide {
    0%, 30% { width: 34px; }
    45%, 75% { width: 0; border-right-width: 0; }
    90%, 100% { width: 34px; }
}

/* --- window shell --- */
.win {
    position: absolute;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: visible;            /* let resize handles straddle the edge */
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), 0 4px 14px rgba(0, 0, 0, 0.14);
    padding: 0;
    min-width: 320px;
    min-height: 200px;
    transition: box-shadow 0.2s ease;
}
.win::before, .win::after { content: none !important; display: none !important; }

.win-inner {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: inherit;
}

/* dark: same subtle border as the CLI terminal — no blue outline */
[data-theme="dark"] .win {
    border-color: #2f2f2f;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.4);
}

.win.is-focused {
    box-shadow: 0 34px 90px rgba(0, 0, 0, 0.34), 0 6px 18px rgba(0, 0, 0, 0.18);
}
[data-theme="dark"] .win.is-focused {
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), 0 6px 20px rgba(0, 0, 0, 0.5);
}

.win.is-min { display: none !important; }

/* open / close pop for the global floating windows (Guide, Settings) */
@keyframes winPopIn  { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes winPopOut { from { opacity: 1; transform: scale(1); }   to  { opacity: 0; transform: scale(0.92); } }
#winHelp.win--opening, #winSettings.win--opening { animation: winPopIn 0.2s cubic-bezier(0.2, 0.8, 0.3, 1); }
#winHelp.win--closing, #winSettings.win--closing { animation: winPopOut 0.16s ease forwards; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
    #winHelp.win--opening, #winSettings.win--opening,
    #winHelp.win--closing, #winSettings.win--closing { animation-duration: 0.01s; }
}

/* transient class: added only while a window animates max / min / restore */
.win--animating {
    transition:
        left 0.26s cubic-bezier(0.34, 1.1, 0.4, 1),
        top 0.26s cubic-bezier(0.34, 1.1, 0.4, 1),
        width 0.26s cubic-bezier(0.34, 1.1, 0.4, 1),
        height 0.26s cubic-bezier(0.34, 1.1, 0.4, 1),
        transform 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease,
        box-shadow 0.2s ease !important;
}

/* --- minimized-window bubbles (top-left of the desktop) --- */
.win-bubbles {
    position: absolute;
    top: 1.1rem;
    left: 1.1rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    align-items: flex-start;
}
/* the Guide is a global window, so its bubble lives at viewport top-left */
.win-bubbles--global { position: fixed; z-index: 1101; }
.win-bubble {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.9rem 0.3rem 0.3rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    animation: bubbleIn 0.22s cubic-bezier(0.34, 1.2, 0.5, 1);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.win-bubble:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.win-bubble .bub-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    display: grid;
    place-items: center;
    color: var(--accent);
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    font-weight: 700;
}
.win-bubble .bub-dot svg { width: 15px; height: 15px; }
.win-bubble .bub-label {
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
}
@keyframes bubbleIn {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}
