/*
 * Tools "desktop" experience.
 * Scoped to the interactive tools landing page (tools/index.html) and loaded
 * separately so the shared css/style.css stays within its size budget.
 *
 * The wallpaper is a pure-CSS gradient bloom in the site's sky-blue accent
 * family, evoking a generic Windows-style desktop without using any
 * copyrighted artwork.
 */

.desktop-hint {
    margin-top: -1rem;
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.tools-desktop {
    --desk-text: #f8fafc;
    --desk-tile-bg: rgb(255 255 255 / 16%);
    --desk-tile-bg-active: rgb(255 255 255 / 30%);
    --desk-tile-border: rgb(255 255 255 / 32%);
    --desk-chrome-bg: rgb(15 23 42 / 38%);
    --desk-bar-bg: rgb(15 23 42 / 55%);
    --desk-bar-border: rgb(255 255 255 / 14%);

    position: relative;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    background:
        radial-gradient(120% 120% at 78% 14%, rgb(125 211 252 / 55%) 0%, rgb(125 211 252 / 0%) 46%),
        radial-gradient(110% 110% at 16% 94%, rgb(14 165 233 / 45%) 0%, rgb(14 165 233 / 0%) 52%),
        linear-gradient(135deg, #0a3d91 0%, #0469c4 48%, #0aa2e0 100%);
}

:root[data-theme="dark"] .tools-desktop {
    --desk-tile-bg: rgb(255 255 255 / 10%);
    --desk-tile-bg-active: rgb(255 255 255 / 22%);
    --desk-tile-border: rgb(255 255 255 / 22%);

    background:
        radial-gradient(120% 120% at 78% 14%, rgb(56 189 248 / 30%) 0%, rgb(56 189 248 / 0%) 46%),
        radial-gradient(110% 110% at 16% 94%, rgb(37 99 235 / 35%) 0%, rgb(37 99 235 / 0%) 52%),
        linear-gradient(135deg, #020617 0%, #0b2350 50%, #0e3a6b 100%);
}

/* Faux window title bar */
.tools-desktop-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0.9rem;
    background: var(--desk-chrome-bg);
    border-bottom: 1px solid var(--desk-bar-border);
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.tools-desktop-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--desk-text);
}

.tools-desktop-winbtns {
    display: inline-flex;
    gap: 0.45rem;
}

.winbtn {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.winbtn-min {
    background: #fbbf24;
}

.winbtn-max {
    background: #34d399;
}

.winbtn-close {
    background: #f87171;
}

/* Desktop surface that holds the icons */
.tools-desktop-surface {
    min-height: 360px;

    /* Wider side padding buys buffer so centred tooltips on wrapped-row edge
       icons (which :first/:last-child can't target) stay inside the desktop. */
    padding: 1.75rem 2rem 2rem;
}

.desktop-icons {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.75rem 0.5rem;
    align-content: start;
    justify-items: center;
}

.desktop-icon-item {
    width: 100%;
    display: flex;
    justify-content: center;
}

.desktop-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 112px;
    padding: 0.6rem 0.35rem 0.7rem;
    border-radius: 12px;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--desk-text);
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.desktop-icon:hover,
.desktop-icon:focus-visible {
    background-color: rgb(255 255 255 / 14%);
    border-color: rgb(255 255 255 / 30%);
    transform: translateY(-2px);
    outline: none;
}

.desktop-icon-glyph {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 15px;
    font-size: 2rem;
    line-height: 1;
    background: var(--desk-tile-bg);
    border: 1px solid var(--desk-tile-border);
    box-shadow: 0 6px 16px rgb(2 6 23 / 28%);

    /* stylelint-disable-next-line property-no-vendor-prefix -- Safari < 18 needs the prefix for the frosted-glass blur */
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: background-color 0.18s ease;
}

.desktop-icon:hover .desktop-icon-glyph,
.desktop-icon:focus-visible .desktop-icon-glyph {
    background: var(--desk-tile-bg-active);
}

.desktop-icon-label {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    color: var(--desk-text);
    text-shadow: 0 1px 3px rgb(2 6 23 / 55%);
    overflow-wrap: anywhere;
}

/* Hover/focus tooltip with the tool's one-line description */
.desktop-icon-tip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    z-index: 6;
    width: max-content;
    max-width: 200px;
    padding: 0.5rem 0.7rem;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.45;
    color: #f8fafc;
    background: rgb(15 23 42 / 96%);
    border: 1px solid rgb(255 255 255 / 12%);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%);
    transition: opacity 0.16s ease, visibility 0.16s ease;
    pointer-events: none;
}

.desktop-icon-tip::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    border: 6px solid transparent;
    border-bottom-color: rgb(15 23 42 / 96%);
    transform: translateX(-50%);
}

.desktop-icon:hover .desktop-icon-tip,
.desktop-icon:focus-visible .desktop-icon-tip {
    opacity: 1;
    visibility: visible;
}

/* Anchor the first/last icon tooltips to the desktop edge so a centred 200px
   bubble can't overflow the container and trigger a horizontal scrollbar. */
.desktop-icon-item:first-child .desktop-icon-tip {
    left: 0;
    transform: none;
}

.desktop-icon-item:first-child .desktop-icon-tip::after {
    left: 30px;
}

.desktop-icon-item:last-child .desktop-icon-tip {
    right: 0;
    left: auto;
    transform: none;
}

.desktop-icon-item:last-child .desktop-icon-tip::after {
    right: 30px;
    left: auto;
}

/* Faux taskbar */
.tools-desktop-taskbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0.75rem;
    background: var(--desk-bar-bg);
    border-top: 1px solid var(--desk-bar-border);
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}

.taskbar-start {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.7rem;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--desk-text);
    text-decoration: none;
    transition: background-color 0.18s ease;
}

.taskbar-start:hover,
.taskbar-start:focus-visible {
    background-color: rgb(255 255 255 / 14%);
    color: var(--desk-text);
}

.taskbar-start:focus-visible {
    outline: 2px solid rgb(255 255 255 / 70%);
    outline-offset: 2px;
}

.taskbar-start-glyph {
    width: 16px;
    height: 16px;
    display: inline-block;
    background:
        linear-gradient(#fff, #fff) 0 0 / 7px 7px no-repeat,
        linear-gradient(#fff, #fff) 9px 0 / 7px 7px no-repeat,
        linear-gradient(#fff, #fff) 0 9px / 7px 7px no-repeat,
        linear-gradient(#fff, #fff) 9px 9px / 7px 7px no-repeat;
}

.taskbar-clock {
    font-size: 0.82rem;
    font-weight: 600;
    color: rgb(248 250 252 / 92%);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

@media (width <= 640px) {
    .tools-desktop-surface {
        min-height: 280px;
        padding: 1.25rem 0.75rem 1.5rem;
    }

    .desktop-icons {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .desktop-icon-glyph {
        width: 52px;
        height: 52px;
        font-size: 1.7rem;
    }

    .desktop-icon-label {
        font-size: 0.76rem;
    }

    /* No hover on touch devices: keep the always-visible labels, drop tooltips */
    .desktop-icon-tip {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .desktop-icon,
    .desktop-icon-glyph,
    .desktop-icon-tip {
        transition: none;
    }

    .desktop-icon:hover,
    .desktop-icon:focus-visible {
        transform: none;
    }
}
