/* Desktop — the landing page as an OS desktop: folders, files, widgets, dock. */

:root {
    /* The desktop predated theme.css and carried its own palette. Every token
       now points at the shared theme so it sits over the board rather than
       clashing with it. */
    --dt-ink: var(--jg-ink);
    --dt-muted: var(--jg-muted);
    --dt-faint: var(--jg-dim);
    --dt-line: var(--jg-line);
    --dt-paper: var(--jg-paper);
    --dt-folder-a: var(--jg-paper);
    --dt-folder-b: var(--jg-stone);
    --dt-red: var(--jg-accent);
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

.desktop-page {
    margin: 0;
    min-height: 100%;
    color: var(--dt-ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- surface ---------- */

.dt-surface {
    position: relative;
    min-height: 100vh;
    padding: 4.75rem clamp(1rem, 3vw, 2.5rem) 8.5rem;
}

/* ---------- icon layer ----------
   Every icon sits in one layer so any of them can be dragged anywhere. Below
   the breakpoint they fall back to flow: dragging on a phone fights scrolling
   and there is no room to arrange anything. */

.dt-icons {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.dt-icons.is-free {
    position: static;
    display: block;
}

/* Anything you can pick up is .dt-drag — the folders, the dock, the trash, and
   the two widgets. Being fixed lifts the widgets out of their column, so they
   need their width back explicitly. */
.dt-surface.is-free .dt-drag {
    position: fixed;
    margin: 0;
    touch-action: none;
}

.dt-surface.is-free .dt-icon { width: 6.2rem; }
.dt-surface.is-free .dt-widget { width: min(23rem, 34vw); }

.dt-drag.is-dragging { cursor: grabbing; }

/* The pad drags by its title bar, like a window. */
.dt-pad-bar { cursor: grab; user-select: none; }
.dt-clock { cursor: grab; }

.dt-icon.is-dragging {
    z-index: 30;
    cursor: grabbing;
    transform: scale(1.06);
    filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.5));
}

.dt-surface.is-free .dt-drag.is-dragging { transition: none; }

/* ---------- folders ---------- */

.dt-icon {
    transition: transform 0.14s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.35rem;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.dt-icon:hover,
.dt-icon:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--glass-edge-soft);
    outline: none;
}

/* Anything sitting straight on the board needs its own ground. The board used
   to be a bare dark field; now it is covered in cream cards, where white type
   measures 2.0:1 even through the scrim. On the chip it is 8.9:1. */
.dt-icon-cap {
    background: rgba(20, 23, 24, 0.7);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    border-radius: 0.45rem;
}

.dt-icon-cap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.26rem 0.55rem 0.3rem;
}

.dt-icon-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--on-glass);
}

/* Folder: three layers — a back panel, contents peeking between, and a front
   panel that tips forward on hover so it reads as opening. Solid rather than
   frosted; the chunky solidity is the point, and a glass folder would be a
   ghost of one. */
.dt-folder {
    position: relative;
    width: 5.4rem;
    height: 4.4rem;
    perspective: 520px;
    transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.dt-icon:hover .dt-folder,
.dt-icon:focus-visible .dt-folder { transform: translateY(-5px); }

/* Back panel, with the tab. */
.f-back {
    position: absolute;
    inset: 0.35rem 0 0 0;
    background: var(--fold-back);
    border-radius: 0.7rem;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.42);
}

.f-back::before {
    content: '';
    position: absolute;
    left: 0.1rem;
    top: -0.42rem;
    width: 46%;
    height: 0.7rem;
    background: var(--fold-back);
    border-radius: 0.45rem 0.45rem 0 0;
}

/* Contents. They sit between the panels and rise as it opens. */
.f-card {
    position: absolute;
    left: 50%;
    bottom: 1.15rem;
    width: 62%;
    height: 2.5rem;
    margin-left: -31%;
    background: #fbfaf6;
    border-radius: 0.34rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.f-card:nth-child(2) { transform: translateY(0) rotate(-4deg) scale(0.94); }
.f-card:nth-child(3) { transform: translateY(0) rotate(2deg) scale(0.97); }
.f-card:nth-child(4) { transform: translateY(0) rotate(0deg); }

.dt-icon:hover .f-card:nth-child(2) { transform: translateY(-13px) rotate(-11deg) scale(0.94); }
.dt-icon:hover .f-card:nth-child(3) { transform: translateY(-16px) rotate(7deg) scale(0.97); }
.dt-icon:hover .f-card:nth-child(4) { transform: translateY(-19px) rotate(-1deg); }

/* Front panel. Tips forward from its bottom edge. */
.f-front {
    position: absolute;
    inset: 1.15rem 0 0 0;
    display: grid;
    place-items: center;
    background: linear-gradient(168deg, var(--fold-front) 0%, var(--fold-front-2) 100%);
    border-radius: 0.7rem;
    transform-origin: bottom center;
    transform: rotateX(0deg);
    transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.4) inset;
}

.dt-icon:hover .f-front,
.dt-icon:focus-visible .f-front { transform: rotateX(-28deg); }

/* Item count under the name. */
.dt-icon-count {
    font-family: var(--jg-mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    color: var(--on-glass-soft);
}

.f-front svg {
    width: 46%;
    height: 46%;
    fill: none;
    stroke: var(--on-glass);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.85;
}

/* Dark ink, uniform across all five folders. Checked on each: 3.0:1 at worst
   (Elsewhere) and 3.5:1 at best (Skills), so no folder needs its own glyph. */
.f-front svg { width: 38%; height: 38%; stroke: rgba(34, 30, 12, 0.62); }



/* ---------- widgets ---------- */

.dt-widgets {
    position: absolute;
    z-index: 30;
    top: 4.75rem;
    right: clamp(1rem, 3vw, 2.5rem);
    width: min(23rem, 34vw);
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.dt-widget {
    background: var(--glass);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-edge);
    border-radius: var(--r-lg);
    box-shadow: var(--glass-lift), var(--glass-inset);
    overflow: hidden;
    color: var(--on-glass);
}

.dt-clock { padding: 1.35rem 1.5rem 1.5rem; }

.dt-time {
    font-size: 2.4rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.dt-date {
    margin-top: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--on-glass-soft);
}

.dt-rule {
    border: 0;
    border-top: 1px solid var(--glass-edge-soft);
    margin: 1.1rem 0;
}

.dt-status {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dt-status-sub {
    margin-top: 0.35rem;
    font-size: 0.74rem;
    color: var(--on-glass-soft);
}

/* ---------- the pad ----------
   A text editor, not stationery. The clock stays a glass panel; this one gets
   window chrome — title bar, menu row, monospace body, status line — so that
   even though it is dark like the ground behind it, it reads as an application
   sitting on the desktop rather than a hole punched in it. Which is the job the
   chrome is doing: the body is only 1.55:1 against the desktop, so the edge and
   the bars are what separate it, not the fill. */

.dt-pad {
    background: #1e2224;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    color: #dfe3df;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
    font-family: var(--jg-mono);
    display: flex;
    flex-direction: column;
}

.dt-pad-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0.6rem;
    background: #14181a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.dt-pad-name { font-size: 0.62rem; letter-spacing: 0.03em; color: #c9cfc9; }
.dt-pad-win { font-size: 0.62rem; letter-spacing: 0.22em; color: #8b948d; }

.dt-pad-menu {
    display: block;
    padding: 0.32rem 0.7rem;
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    color: #9aa39c;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: pre;
}

/* A real text area, because the point is that you can type in it. Contents
   measure 12.4:1 on the editor body. */
.dt-pad-text {
    display: block;
    width: 100%;
    height: 15.5rem;
    padding: 0.75rem 0.9rem;
    border: 0;
    resize: none;
    background: transparent;
    color: #dfe3df;
    font-family: var(--jg-mono);
    font-size: 0.72rem;
    line-height: 1.65;
    /* An editor does not wrap at a word boundary and neither does this. */
    white-space: pre;
    overflow: auto;
    tab-size: 4;
}

.dt-pad-text:focus { outline: none; background: rgba(255, 255, 255, 0.03); }
.dt-pad-text::selection { background: rgba(232, 163, 61, 0.35); }
.dt-pad-text::placeholder { color: #6f7872; }

.dt-pad-status {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.3rem 0.7rem;
    background: #14181a;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    font-size: 0.58rem;
    letter-spacing: 0.05em;
    color: #8b948d;
}

/* ---------- dock + trash ---------- */

/* Lit while something is hovering over it, so a drop is never a guess. */
.dt-trash-icon-wrap.is-over .dt-trash-icon {
    background: var(--jg-accent);
    border-color: var(--jg-accent);
    transform: scale(1.12);
}

.dt-trash-icon-wrap.is-full .dt-trash-icon { border-color: var(--jg-accent); }
.dt-trash-icon-wrap.is-full .dt-icon-count { color: var(--jg-accent); }


/* A tile like the others, with the bin drawn inside it rather than the tile
   itself being bin-shaped — a clip-path cannot carry a rounded glass edge. */
.dt-trash-icon {
    position: relative;
    display: block;
    width: 4.6rem;
    height: 4.6rem;
    background: var(--glass);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-edge);
    border-radius: var(--r-md);
    box-shadow: var(--glass-lift), var(--glass-inset);
    transition: background 0.15s linear, transform 0.15s ease-out;
}

.dt-icon:hover .dt-trash-icon { background: var(--glass-strong); transform: translateY(-2px); }

/* bin body */
.dt-trash-icon::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 40%;
    transform: translate(-50%, -50%);
    width: 1.5rem;
    height: 1.6rem;
    border: 1.7px solid var(--on-glass);
    border-top: 0;
    border-radius: 0 0 5px 5px;
    opacity: 0.85;
}

.dt-trash-icon::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 34%;
    transform: translate(-50%, -50%);
    width: 2rem;
    height: 1.7px;
    background: var(--on-glass);
    border-radius: 2px;
    opacity: 0.85;
}

/* ---------- window ---------- */
/* `display: flex` below outranks the UA stylesheet's [hidden] rule, so the
   attribute needs restating or the empty window shows permanently. */
[hidden] { display: none !important; }


/* ---------- responsive ---------- */

@media (max-width: 1100px) {
    .dt-widgets {
        position: static;
        width: auto;
        margin: 2.5rem 0 0;
    }
    .dt-surface {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding-bottom: 3rem;
    }
}

/* ---------- desktop as a layer over the board ----------
   The board is the ground; the desktop is furniture standing on it. Entering
   clears the furniture rather than loading a page. */

.dt-layer {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow-y: auto;
    /* The layer covers the viewport, so by default it would swallow every
       click meant for the dice underneath. Only the furniture itself is a
       target; the gaps between it belong to the board. */
    pointer-events: none;
    /* Scaled from slightly above centre, so entering reads as moving through
       the desktop rather than dissolving it. */
    transform-origin: 50% 42%;
    transition: opacity 380ms ease-out, transform 760ms cubic-bezier(0.6, 0, 0.3, 1);
}

.dt-icons,
.dt-widgets { pointer-events: auto; }

.is-board .dt-layer {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.04);
}

/* ---------- paintball ----------
   A canvas over everything, plus the marker itself. Inert until armed, so it
   never intercepts a click meant for the page. */

.pb-canvas {
    position: fixed;
    inset: 0;
    z-index: 300;
    pointer-events: none;
}

.pb-gun {
    position: fixed;
    z-index: 310;
    right: clamp(1rem, 5vw, 5rem);
    bottom: -2rem;
    width: clamp(11rem, 22vw, 17rem);
    pointer-events: none;
    opacity: 0;
    transform: translateY(60%) rotate(-8deg);
    transform-origin: 80% 80%;
    transition: opacity 260ms ease-out, transform 320ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
    filter: drop-shadow(-8px 10px 0 rgba(0, 0, 0, 0.35));
}

.is-armed .pb-gun { opacity: 1; transform: translateY(0) rotate(-8deg); }
.pb-gun svg { display: block; width: 100%; height: auto; }

/* Recoil. Restarted per shot by toggling the class. */
.pb-gun.is-kick { animation: pb-kick 130ms ease-out; }

@keyframes pb-kick {
    0%   { transform: translateY(0) rotate(-8deg); }
    35%  { transform: translate(10px, 12px) rotate(-2deg); }
    100% { transform: translateY(0) rotate(-8deg); }
}

/* Armed: the page becomes a target, but the rail and dock stay usable. */
.is-armed { cursor: crosshair; }
/* Everything you can still click while armed keeps a normal cursor. The rail
   was missing from this list and the menubar was in it twice. */
.is-armed .menubar,
.is-armed .dt-icon,
.is-armed .pb-exit { cursor: default; }

.pb-exit {
    position: fixed;
    z-index: 320;
    left: 50%;
    bottom: 1.4rem;
    transform: translateX(-50%);
    display: none;
    gap: 0.5rem;
    align-items: center;
    background: var(--glass-strong);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-edge);
    border-radius: var(--r-pill);
    padding: 0.45rem 0.8rem;
    font-family: var(--jg-mono);
    font-size: 0.64rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--jg-muted);
}

.is-armed .pb-exit { display: flex; }

.pb-exit button {
    font: inherit;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--glass-edge);
    border-radius: var(--r-pill);
    color: var(--on-glass);
    padding: 0.15rem 0.5rem;
}

.pb-exit button:hover { background: var(--jg-accent); color: #1a1c1c; }

@media (prefers-reduced-motion: reduce) {
    .pb-gun, .pb-gun.is-kick { transition: none; animation: none; }
}

/* Without backdrop-filter the fills still composite correctly — contrast is
   unchanged, only the blur is missing — but a touch more body keeps the
   panels reading as objects rather than tints. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .dt-widget,
    .dt-trash-icon { background: rgba(255, 255, 255, 0.62); }
    .dt-trash-icon::before { background: rgba(255, 255, 255, 0.72); }
}

@media (max-width: 1100px) {
    /* A scrolling document again: the layer needs the gaps back to be
       scrollable, and there is no dice to reach past it. This block sits
       after the base rule on purpose — a media query adds no specificity. */
    .dt-layer { pointer-events: auto; }

    /* An editor does not wrap, but a phone has no room for a horizontal
       scrollbar inside a card inside a scrolling page. It wraps here. */
    .dt-pad-text { white-space: pre-wrap; height: 12rem; font-size: 0.76rem; }
    .dt-widget { width: auto; }
}

@media (max-width: 700px) {
    .dt-icons { gap: 0.7rem; justify-content: flex-start; }
    .dt-pad-text { height: 10.5rem; }
    /* Nothing drags below the breakpoint, so the grab cursors are a lie. */
    .dt-pad-bar, .dt-clock { cursor: default; }
}
