/* ------------------------------------------------------------------ *
 * Werkzeugkasten – Design angelehnt an CDE / Solaris (Motif)
 *   - lila-graue Oberflaeche
 *   - abgeschraegte 3D-Raender (Bevel): hell oben/links, dunkel unten/rechts
 * ------------------------------------------------------------------ */

:root {
    --face:        #b7b7c9;  /* Grundflaeche, lila-grau            */
    --face-light:  #c6c6d6;  /* Kacheln / Panels                   */
    --bevel-hi:    #e6e6f0;  /* Lichtkante                         */
    --bevel-lo:    #6e6e84;  /* Schattenkante                      */
    --bevel-lo2:   #4c4c60;  /* tiefere Schattenkante              */
    --title:       #5b5b7e;  /* Titelleiste                        */
    --title-hi:    #7a7aa0;
    --ink:         #1d1d28;  /* Text                               */
    --ink-soft:    #3a3a4c;
}

* { box-sizing: border-box; }

html { overflow-y: scroll; }
html, body {
    margin: 0;
    min-height: 100%;
}

body {
    background-color: var(--face);
    /* wiederholendes Muster hinter dem Fenster */
    background-image: url('../pattern.png');
    background-repeat: repeat;
    font-family: "Bitstream Vera Sans", Verdana, Geneva, "DejaVu Sans", sans-serif;
    color: var(--ink);
    padding: 24px;
}

/* --- Fensterrahmen --------------------------------------------------- */
.window {
    max-width: 980px;
    margin: 0 auto;
    background: var(--face);
    border-top: 2px solid var(--bevel-hi);
    border-left: 2px solid var(--bevel-hi);
    border-right: 2px solid var(--bevel-lo2);
    border-bottom: 2px solid var(--bevel-lo2);
    box-shadow: 3px 3px 0 rgba(0,0,0,.25);
}

/* --- Titelleiste ----------------------------------------------------- */
.titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;        /* gleiche Höhe wie die Tool-Titelzeilen */
    /* rechts wie der Arbeitsbereich (16px) + 1px optische Korrektur: die letzte Kachelspalte endet
       durch die 1fr-Aufteilung einen Sub-Pixel vor der Rasterkante und wird beim Zeichnen abgerundet */
    padding: 5px 17px 5px 7px;
    background: linear-gradient(var(--title-hi), var(--title));
    color: #fff;
    border-top: 2px solid var(--bevel-hi);
    border-left: 2px solid var(--bevel-hi);
    border-right: 2px solid var(--bevel-lo2);
    border-bottom: 2px solid var(--bevel-lo2);
    margin: 3px;
}
.tb-title {
    flex: 1;
    font-weight: bold;
    letter-spacing: .5px;
    text-shadow: 1px 1px 0 rgba(0,0,0,.4);
}
.tb-back {
    font-size: 13px; text-decoration: none;
    background: var(--face-light); color: var(--ink);
    padding: 1px 8px;
    border-top: 2px solid var(--bevel-hi);
    border-left: 2px solid var(--bevel-hi);
    border-right: 2px solid var(--bevel-lo);
    border-bottom: 2px solid var(--bevel-lo);
}
.tb-back:active {
    border-top: 2px solid var(--bevel-lo);
    border-left: 2px solid var(--bevel-lo);
    border-right: 2px solid var(--bevel-hi);
    border-bottom: 2px solid var(--bevel-hi);
}
/* Umschalter fuer den Bearbeiten-Modus: quadratisch, gleiche Hoehe wie das Suchfeld */
.tb-edit {
    flex: none;
    width: 22px;
    height: 22px;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--face-light);
    color: var(--ink);
    cursor: pointer;
    border-top: 2px solid var(--bevel-hi);
    border-left: 2px solid var(--bevel-hi);
    border-right: 2px solid var(--bevel-lo);
    border-bottom: 2px solid var(--bevel-lo);
}
.tb-edit svg { width: 15px; height: 15px; display: block; }
.tb-edit:hover { background: #d4d4e2; }
.tb-edit:active,
.tb-edit[aria-pressed="true"] {
    /* gedrueckt: Bevel umkehren */
    background: #c2c2d4;
    border-top: 2px solid var(--bevel-lo);
    border-left: 2px solid var(--bevel-lo);
    border-right: 2px solid var(--bevel-hi);
    border-bottom: 2px solid var(--bevel-hi);
}

.tb-filter {
    height: 22px;                 /* haelt die Titelleiste auf 36px Hoehe (Leiste hat 2px-Rahmen + 5px-Padding) */
    box-sizing: border-box;
    font-family: inherit;
    font-size: 13px;
    padding: 1px 9px;
    background: #fff;
    color: var(--ink);
    width: min(46vw, 230px);
    border-top: 2px solid var(--bevel-lo);
    border-left: 2px solid var(--bevel-lo);
    border-right: 2px solid var(--bevel-hi);
    border-bottom: 2px solid var(--bevel-hi);
}
.tb-btn, .tb-square {
    display: inline-block;
    width: 16px; height: 16px;
    background: var(--face-light);
    border-top: 2px solid var(--bevel-hi);
    border-left: 2px solid var(--bevel-hi);
    border-right: 2px solid var(--bevel-lo);
    border-bottom: 2px solid var(--bevel-lo);
}
.tb-square { cursor: pointer; }
.tb-square:active {
    border-top: 2px solid var(--bevel-lo);
    border-left: 2px solid var(--bevel-lo);
    border-right: 2px solid var(--bevel-hi);
    border-bottom: 2px solid var(--bevel-hi);
}
.tb-btns { display: flex; gap: 4px; }

/* Konfetti-Knöpfe in der Titelleiste */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }
.tb-square.active {
    background: var(--title-hi);
    border-top: 2px solid var(--bevel-lo);
    border-left: 2px solid var(--bevel-lo);
    border-right: 2px solid var(--bevel-hi);
    border-bottom: 2px solid var(--bevel-hi);
}

/* --- Arbeitsflaeche (eingelassen) ----------------------------------- */
.workspace {
    margin: 3px;
    padding: 16px;
    background: var(--face);
    /* inset bevel */
    border-top: 2px solid var(--bevel-lo);
    border-left: 2px solid var(--bevel-lo);
    border-right: 2px solid var(--bevel-hi);
    border-bottom: 2px solid var(--bevel-hi);
}

/* --- Breadcrumb ------------------------------------------------------ */
.breadcrumb {
    font-size: 13px;
    margin-bottom: 16px;
    color: var(--ink-soft);
}
.breadcrumb a { color: var(--title); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 6px; color: var(--bevel-lo); }
.breadcrumb .here { font-weight: bold; }

/* --- Kachelraster ---------------------------------------------------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}
/* versteckte Raster wirklich ausblenden (sonst überschreibt display:grid das hidden-Attribut) */
.grid[hidden] { display: none; }

.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 10px 12px;
    text-decoration: none;
    color: var(--ink);
    background: var(--face-light);
    border-top: 2px solid var(--bevel-hi);
    border-left: 2px solid var(--bevel-hi);
    border-right: 2px solid var(--bevel-lo);
    border-bottom: 2px solid var(--bevel-lo);
    cursor: pointer;
}
.tile:hover { background: #cfcfdd; }

/* Bearbeiten-Modus: Kacheln schwingen leicht hin und her */
@keyframes tilewobble {
    0%, 100% { transform: rotate(-1.4deg); }
    50%      { transform: rotate(1.4deg); }
}
.grid.editing .tile {
    animation: tilewobble .34s ease-in-out infinite;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;   /* kein Vorschau-/Kontextmenue bei langem Halten (Touch) */
}
.grid.editing .tile:nth-child(2n)   { animation-delay: -.17s; }
.grid.editing .tile:nth-child(3n+1) { animation-delay: -.09s; }
.grid.editing .tile.dragsrc { animation: none; }
.grid.editing .tile.pinlast { animation: none; cursor: default; }   /* „Tool vorschlagen" ist fixiert */
@media (prefers-reduced-motion: reduce) {
    .grid.editing .tile { animation: none; }
}

/* Umsortieren per Ziehen */
.grid.reordering { cursor: grabbing; }
.grid.reordering .tile { user-select: none; -webkit-user-select: none; }
.tile.dragsrc { opacity: .3; }
.tile.tileghost {
    position: fixed;
    z-index: 999;
    margin: 0;
    pointer-events: none;
    opacity: .95;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, .3);
}
.tile:active {
    /* gedrueckt: Bevel umkehren */
    border-top: 2px solid var(--bevel-lo);
    border-left: 2px solid var(--bevel-lo);
    border-right: 2px solid var(--bevel-hi);
    border-bottom: 2px solid var(--bevel-hi);
    padding: 17px 9px 11px 11px;
}

.tile .icon {
    width: 64px; height: 64px;
    display: flex; align-items: center; justify-content: center;
}
.tile .icon img {
    max-width: 100%; max-height: 100%;
    image-rendering: -webkit-optimize-contrast;
}
.tile .label {
    text-align: center;
    font-size: 13px;
    line-height: 1.25;
    word-break: break-word;
}
.tile .cat {
    text-align: center;
    font-size: 11px;
    line-height: 1.2;
    color: var(--ink-soft);
}

/* Kategorien optisch leicht abheben: gesamte Kachel etwas dunkler */
.tile.folder { background: #aaaabf; }
.tile.folder:hover { background: #b8b8cc; }
.tile.folder .label { font-weight: bold; }
.tile.up .label { color: var(--ink-soft); }

.empty {
    grid-column: 1 / -1;
    color: var(--ink-soft);
    font-size: 14px;
}
.empty code {
    background: var(--face-light);
    padding: 1px 5px;
    border: 1px solid var(--bevel-lo);
}

/* --- Footer (Datenschutz / Impressum) ------------------------------- */
.footer {
    max-width: 980px;
    margin: 16px auto 0;
    text-align: center;
    font-size: 13px;
    color: var(--ink);
}
.footer a {
    color: var(--ink);
    text-decoration: none;
    margin: 0 4px;
    transition: color .15s;
}
.footer a:hover { color: var(--title); text-decoration: underline; }
