/* ============================================================
   Web-Apps-Übersicht auf der Startseite (#apps)
   ------------------------------------------------------------
   Vorauswahl über die vier Inhaltsbereiche (KMK), Filter nach
   Klassenstufe und Suche. Gesteuert von js/apps-uebersicht.js;
   ohne JavaScript erscheinen alle Apps nach Bereichen gruppiert.

   Bereichsfarben exakt wie im Buch-Leitsystem der
   Unterrichtshilfen (css/unterrichtshilfen.css). Für den
   dunklen Hintergrund gibt es je eine aufgehellte Variante.
   ============================================================ */

#apps.apps-bereich {
    --ap-dunkel: #15344b;
    --ap-text: #15344b;
    --ap-grau: #5d6d7c;
    --ap-linie: #e3e8ed;

    --ap-zo:  #31699C;  /* Zahlen und Operationen */
    --ap-rf:  #4E8A56;  /* Raum und Form */
    --ap-gm:  #C07A2A;  /* Größen und Messen */
    --ap-dhw: #7D5BA6;  /* Daten, Häufigkeit und Wahrscheinlichkeit */

    /* dunklere Varianten nur als Hintergrund kleiner weißer Schrift (WCAG 4,5:1) */
    --ap-rf-text:  #467E4E;
    --ap-gm-text:  #A0651F;

    --ap-zo-hell:  #8fbbe6;
    --ap-rf-hell:  #95cc9c;
    --ap-gm-hell:  #efb56e;
    --ap-dhw-hell: #c0a6e4;

    position: relative;
    padding: 110px 0 90px;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background-color: #15344b;
    /* dezentes Punktefeld + weicher Lichtschein von oben */
    background-image:
        radial-gradient(ellipse 70% 45% at 50% 0%, rgba(154,205,50,0.10) 0%, rgba(154,205,50,0) 70%),
        radial-gradient(rgba(255,255,255,0.075) 1.2px, transparent 1.4px);
    background-size: 100% 100%, 26px 26px;
    background-position: 0 0, 13px 13px;
}

/* hidden muss auch gegen display:flex/grid gewinnen */
#apps [hidden] { display: none !important; }

/* Bereichsvariablen je Element */
#apps .b-zo  { --b: var(--ap-zo);  --b-text: var(--ap-zo);      --b-hell: var(--ap-zo-hell);  --b-tint: rgba(49,105,156,0.11);  }
#apps .b-rf  { --b: var(--ap-rf);  --b-text: var(--ap-rf-text); --b-hell: var(--ap-rf-hell);  --b-tint: rgba(78,138,86,0.12);   }
#apps .b-gm  { --b: var(--ap-gm);  --b-text: var(--ap-gm-text); --b-hell: var(--ap-gm-hell);  --b-tint: rgba(192,122,42,0.12);  }
#apps .b-dhw { --b: var(--ap-dhw); --b-text: var(--ap-dhw);     --b-hell: var(--ap-dhw-hell); --b-tint: rgba(125,91,166,0.12);  }

/* ---------- Kopf ------------------------------------------- */

.apps-kopf {
    text-align: center;
    max-width: 780px;
    margin: 0 auto 44px;
}

.apps-kicker {
    color: yellowgreen;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 12.5px;
    font-weight: 600;
    margin: 0 0 10px;
}

.apps-kopf h2 {
    color: #fff;
    font-size: 40px;
    font-weight: 300;
    letter-spacing: 0.01em;
    margin: 0 0 16px;
}

.apps-lead {
    color: rgba(255,255,255,0.80);
    font-size: 17.5px;
    font-weight: 300;
    line-height: 1.65;
    margin: 0 auto;
}

.apps-kennzahlen {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 24px 0 0;
}

.apps-kennzahlen li {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    padding: 7px 16px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 300px;
    background: rgba(255,255,255,0.04);
    font-size: 14px;
    color: rgba(255,255,255,0.78);
}

.apps-kennzahlen strong {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

/* ---------- Bereichskacheln (Vorauswahl) ------------------- */

.apps-schritt {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px;
    color: rgba(255,255,255,0.62);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.apps-schritt::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: rgba(255,255,255,0.12);
}

/* Die Klasse „js“ setzt ein Einzeiler im <head>, also schon vor dem ersten Bild:
   ohne JavaScript hätten die Kacheln keine Funktion; mit JavaScript sollen die
   Bereichsgruppen nicht erst aufblitzen, bevor das Skript die Auswahl herstellt */
html:not(.js) #apps .apps-schritt,
html:not(.js) #apps .bereich-wahl { display: none; }
html.js #apps:not(.apps-js) .app-gruppe:not(.app-gruppe--neu) { display: none; }

.bereich-wahl {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.bereich-kachel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    min-height: 100%;
    padding: 24px 22px 20px;
    border: 1px solid rgba(255,255,255,0.13);
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    transition: transform .25s ease, background-color .25s ease, border-color .25s ease, box-shadow .25s ease, opacity .25s ease;
    -webkit-tap-highlight-color: transparent;
}

.bereich-kachel::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 4px;
    background: var(--b-hell);
}

@media (hover: hover) {
    .bereich-kachel:hover {
        transform: translateY(-3px);
        background: rgba(255,255,255,0.09);
        border-color: var(--b-hell);
        box-shadow: 0 12px 30px rgba(0,0,0,0.22);
    }
}

.bereich-kachel:focus:not(:focus-visible) { outline: none; }
.bereich-kachel:focus-visible {
    outline: 3px solid yellowgreen;
    outline-offset: 3px;
}

.bereich-kachel__bild {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    border-radius: 15px;
    background: rgba(255,255,255,0.07);
    color: var(--b-hell);
    transition: background-color .25s, color .25s;
}

.bereich-kachel__bild svg {
    width: 42px;
    height: 42px;
    display: block;
}

.bereich-kachel__text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto;
    align-self: stretch;
    min-width: 0;
}

.bereich-kachel__kuerzel {
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--b-text);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.5;
}

.bereich-kachel__name {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: #fff;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.bereich-kachel__info {
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255,255,255,0.66);
}

.bereich-kachel__fuss {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.10);
    font-size: 14px;
    color: rgba(255,255,255,0.72);
}

.bereich-kachel__anzahl strong {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-right: 4px;
}

.bereich-kachel__pfeil {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.22);
    font-size: 11px;
    transition: transform .25s, background-color .25s, border-color .25s, color .25s;
}

.bereich-kachel:hover .bereich-kachel__pfeil {
    transform: translateX(3px);
    border-color: var(--b-hell);
    color: var(--b-hell);
}

/* gewählt */
.bereich-kachel[aria-pressed="true"] {
    background: #fff;
    border-color: #fff;
    box-shadow: 0 16px 38px rgba(0,0,0,0.30), 0 0 0 3px var(--b-hell);
    transform: translateY(-3px);
}

.bereich-kachel[aria-pressed="true"]::before { background: var(--b); }
.bereich-kachel[aria-pressed="true"] .bereich-kachel__bild { background: var(--b-tint); color: var(--b); }
.bereich-kachel[aria-pressed="true"] .bereich-kachel__name { color: var(--ap-text); }
.bereich-kachel[aria-pressed="true"] .bereich-kachel__info { color: var(--ap-grau); }
.bereich-kachel[aria-pressed="true"] .bereich-kachel__fuss { color: var(--ap-grau); border-top-color: var(--ap-linie); }
.bereich-kachel[aria-pressed="true"] .bereich-kachel__anzahl strong { color: var(--b-text); }
.bereich-kachel[aria-pressed="true"] .bereich-kachel__pfeil {
    background: var(--b-text);
    border-color: var(--b-text);
    color: #fff;
    transform: rotate(90deg);
}

/* andere Kacheln treten zurück, sobald eine gewählt ist */
.bereich-wahl.hat-auswahl .bereich-kachel[aria-pressed="false"] { background: rgba(255,255,255,0.025); }
.bereich-wahl.hat-auswahl .bereich-kachel[aria-pressed="false"] .bereich-kachel__bild,
.bereich-wahl.hat-auswahl .bereich-kachel[aria-pressed="false"]::before { opacity: 0.45; }
.bereich-wahl.hat-auswahl .bereich-kachel[aria-pressed="false"] .bereich-kachel__name { color: rgba(255,255,255,0.82); }
.bereich-wahl.hat-auswahl .bereich-kachel[aria-pressed="false"] .bereich-kachel__info { color: rgba(255,255,255,0.60); }

/* ---------- Werkzeugleiste: Klasse, Suche, Alle ------------ */

.apps-werkzeug {
    display: none; /* nur mit JavaScript sinnvoll */
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
    padding: 14px 16px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    background: rgba(9,28,42,0.45);
}

html.js #apps .apps-werkzeug { display: flex; }

.klassen-wahl {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.apps-werkzeug__label {
    margin-right: 6px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.62);
}

.filter-chip {
    min-width: 44px;
    height: 44px;
    padding: 0 14px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 300px;
    background: transparent;
    color: rgba(255,255,255,0.88);
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s;
}

.filter-chip:hover { border-color: yellowgreen; color: #fff; }
.filter-chip:focus:not(:focus-visible) { outline: none; }
.filter-chip:focus-visible { outline: 3px solid yellowgreen; outline-offset: 2px; }

.filter-chip[aria-pressed="true"] {
    background: yellowgreen;
    border-color: yellowgreen;
    color: #15344b;
}

.apps-suche {
    position: relative;
    flex: 1 1 260px;
    min-width: 0;
}

.apps-suche .glyphicon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.55);
    font-size: 14px;
    pointer-events: none;
}

.apps-suche input {
    width: 100%;
    height: 42px;
    padding: 0 16px 0 40px;
    border: 1px solid rgba(255,255,255,0.45);
    border-radius: 300px;
    background: rgba(255,255,255,0.07);
    color: #fff;
    font: inherit;
    font-size: 16px;
    transition: border-color .2s, background-color .2s, box-shadow .2s;
    -webkit-appearance: none;
    appearance: none;
}

.apps-suche input::placeholder { color: rgba(255,255,255,0.62); opacity: 1; }

.apps-suche input:focus {
    outline: 3px solid yellowgreen;
    outline-offset: 2px;
    border-color: yellowgreen;
    background: rgba(255,255,255,0.11);
}

.apps-alle-knopf {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 20px;
    border: 2px solid yellowgreen;
    border-radius: 300px;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color .2s, color .2s;
}

.apps-alle-knopf .glyphicon { font-size: 12px; color: yellowgreen; transition: color .2s; }
.apps-alle-knopf:hover { background: rgba(154,205,50,0.18); }
.apps-alle-knopf[aria-pressed="true"] { background: yellowgreen; color: #15344b; }
.apps-alle-knopf[aria-pressed="true"] .glyphicon { color: #15344b; }
.apps-alle-knopf:focus:not(:focus-visible) { outline: none; }
.apps-alle-knopf:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ---------- Statuszeile ------------------------------------ */

.apps-status {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    min-height: 30px;
    margin: 22px 0 6px;
    font-size: 15px;
    color: rgba(255,255,255,0.78);
}

#apps.apps-js .apps-status { display: flex; }

.apps-status strong { color: #fff; }
.apps-status__text { margin: 0; font-size: 15px; }

.apps-zuruecksetzen {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 300px;
    background: transparent;
    color: rgba(255,255,255,0.85);
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}

.apps-zuruecksetzen:hover { border-color: yellowgreen; color: yellowgreen; }
.apps-zuruecksetzen:focus:not(:focus-visible) { outline: none; }
.apps-zuruecksetzen:focus-visible { outline: 3px solid yellowgreen; outline-offset: 2px; }
.apps-zuruecksetzen .glyphicon { font-size: 11px; }

/* ---------- App-Gruppen ------------------------------------ */

.app-gruppe { margin-top: 30px; }

.app-gruppe__kopf {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.app-gruppe__titel {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 21px;
    font-weight: 600;
    line-height: 1.35;
    color: #fff;
}

.app-gruppe__zahl {
    display: inline-block;
    min-width: 28px;
    padding: 1px 9px;
    border-radius: 300px;
    background: rgba(255,255,255,0.12);
    font-size: 13.5px;
    font-weight: 700;
    text-align: center;
    color: rgba(255,255,255,0.9);
}

.app-gruppe__unterzeile {
    margin: 0;
    font-size: 14.5px;
    color: rgba(255,255,255,0.62);
}

.bereich-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--b-text);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.5;
}

/* pulsierender Punkt wie bei „Neueste Videos“ (Animation mvl-pulse aus custom.css) */
.apps-puls {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin: 0 4px 0 2px;
    border-radius: 50%;
    background: yellowgreen;
    box-shadow: 0 0 0 4px rgba(154,205,50,0.2);
    animation: mvl-pulse 2.4s ease-in-out 2 paused;
}

.apps-puls.laeuft { animation-play-state: running; }

.app-liste {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.app-eintrag { display: flex; }

/* ---------- App-Karte -------------------------------------- */

.app-karte {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
    padding: 18px 44px 16px 18px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: #fff;
    color: var(--ap-text);
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.16);
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.app-karte:hover,
.app-karte:focus {
    color: var(--ap-text);
    text-decoration: none;
}

@media (hover: hover) {
    .app-karte:hover {
        transform: translateY(-3px);
        border-color: var(--b);
        box-shadow: 0 14px 32px rgba(0,0,0,0.28);
    }
}

.app-karte:focus:not(:focus-visible) { outline: none; }
.app-karte:focus-visible {
    outline: 3px solid yellowgreen;
    outline-offset: 3px;
}

.app-karte__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 13px;
    background: var(--b-tint);
    color: var(--b);
    font-size: 22px;
    transition: background-color .22s, color .22s;
}

.app-karte:hover .app-karte__icon {
    background: var(--b);
    color: #fff;
}

.app-karte__inhalt {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    flex: 1 1 auto;
}

.app-karte__titel {
    overflow-wrap: break-word;
    font-size: 16.5px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ap-text);
}

.app-karte__text {
    overflow-wrap: break-word;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--ap-grau);
}

.app-karte__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.app-karte__bereich {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--b-text);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    line-height: 1.6;
}

.app-karte__klasse {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 300px;
    background: #eef2f5;
    color: #3d5163;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.6;
}

.app-karte__neu {
    position: absolute;
    top: -9px;
    right: 14px;
    padding: 2px 10px;
    border-radius: 300px;
    background: yellowgreen;
    color: #15344b;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: 0 3px 10px rgba(0,0,0,0.20);
}

.app-karte__pfeil {
    position: absolute;
    right: 16px;
    top: 50%;
    margin-top: -8px;
    font-size: 14px;
    color: #b6c2cc;
    transition: transform .22s, color .22s;
}

.app-karte:hover .app-karte__pfeil {
    transform: translateX(4px);
    color: var(--b);
}

/* sanftes Einblenden nach dem Filtern */
@keyframes ap-ein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.app-eintrag.ist-neu-eingeblendet {
    animation: ap-ein .35s ease both;
}

/* ---------- Hinweise / leere Treffer ----------------------- */

.apps-hinweis {
    display: none;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 28px;
    padding: 18px 22px;
    border: 1px dashed rgba(255,255,255,0.22);
    border-radius: 14px;
    text-align: center;
    font-size: 15.5px;
    color: rgba(255,255,255,0.78);
}

#apps.apps-js .apps-hinweis { display: flex; }

.apps-leer {
    margin-top: 26px;
    padding: 30px 22px;
    border-radius: 14px;
    background: rgba(255,255,255,0.05);
    text-align: center;
    color: rgba(255,255,255,0.8);
    font-size: 16px;
}

.apps-leer p { margin: 0 0 14px; }

/* ---------- Bonus: Retro-Spiel ------------------------------ */

.apps-bonus {
    margin-top: 70px;
    padding-top: 34px;
    border-top: 1px solid rgba(255,255,255,0.10);
    text-align: center;
}

.apps-bonus p {
    color: rgba(255,255,255,0.62);
    font-size: 14px;
    margin: 0 0 14px;
}

.apps-bonus a {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border: 1px solid rgba(0,255,255,0.35);
    border-radius: 300px;
    color: #00ffff;
    text-decoration: none;
    font-weight: 600;
    transition: box-shadow .25s, border-color .25s, color .25s;
}

.apps-bonus a:hover,
.apps-bonus a:focus {
    color: #00ffff;
    text-decoration: none;
    border-color: #00ffff;
    box-shadow: 0 0 18px rgba(0,255,255,0.35);
}

.apps-bonus a .glyphicon { font-size: 18px; }
.apps-bonus small { color: rgba(255,255,255,0.62); font-weight: 400; }

/* ---------- Responsiv --------------------------------------- */

@media (max-width: 991px) {
    .bereich-wahl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .apps-alle-knopf { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 767px) {
    #apps.apps-bereich { padding: 80px 0 70px; }
    .apps-kopf h2 { font-size: 32px; }
    .apps-lead { font-size: 16px; }
    .apps-werkzeug { padding: 12px; }
}

@media (max-width: 560px) {
    .bereich-wahl { gap: 12px; }
    .bereich-kachel { padding: 18px 14px 14px; gap: 10px; border-radius: 14px; }
    .bereich-kachel__bild { width: 46px; height: 46px; border-radius: 12px; }
    .bereich-kachel__bild svg { width: 30px; height: 30px; }
    .bereich-kachel__name { font-size: 15.5px; }
    .bereich-kachel__info { display: none; }
    .bereich-kachel__fuss { padding-top: 10px; font-size: 13px; }
    .bereich-kachel__anzahl strong { font-size: 17px; }
    .bereich-kachel__pfeil { width: 26px; height: 26px; }
    .app-liste { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .app-gruppe__titel { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .bereich-kachel,
    .app-karte,
    .app-karte__pfeil,
    .bereich-kachel__pfeil { transition: none; }
    .bereich-kachel:hover,
    .bereich-kachel[aria-pressed="true"],
    .app-karte:hover { transform: none; }
    .app-eintrag.ist-neu-eingeblendet { animation: none; }
    .apps-puls { animation: none; }
}
