/* Alpine.js: Elemente mit x-cloak bis zur Initialisierung verstecken. */
[x-cloak] { display: none !important; }

/* Fertigkeitsbaum (HERO-16): Skill-Marker auf dem Baum-Bild */
.skill-map {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

.skill-map img,
.skill-image {
    display: block;
    max-width: 100%;
    height: auto;
}

.skill-marker {
    position: absolute;
    z-index: 10;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #3b250f;
    background: rgba(255, 230, 120, 0.85);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
    transition: transform .1s ease;
}

.skill-marker:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

/* Gold = noch nicht erlernt, Grün = erlernt */
.skill-marker.unlearned {
    background: rgba(255, 230, 120, 0.85);
}

.skill-marker.learned {
    background: #21ba45;
}

.skill-marker.learned::after {
    content: "✓";
    color: #fff;
    font-size: 14px;
    line-height: 24px;
    display: block;
    text-align: center;
}

/* SKILL-06: Gesperrte Fertigkeiten (Voraussetzungen nicht erfüllt). */
.skill-marker.locked {
    background: rgba(180, 180, 180, 0.6);
    opacity: 0.7;
}

.skill-marker.locked::after {
    content: "🔒";
    font-size: 11px;
    line-height: 24px;
    display: block;
    text-align: center;
}

/* ===========================================================================
   Modal-Höhenbegrenzung (Tablet-Tauglichkeit)
   ---------------------------------------------------------------------------
   Fomantic begrenzt .scrolling.content bereits auf max-height: calc(80vh-10rem)
   mit overflow:auto; zusammen mit dem starren Header und Footer (.actions)
   bleibt ein Modal damit von Haus aus unter ~80vh – also klar unter 95vh.

   Das Show/Hide steuert Fomantic über `display` (none ⇄ block !important).
   Deshalb darf hier KEINE globale `.ui.modal { display: ... !important }`-
   Regel gesetzt werden – sie würde versteckte Modale sichtbar machen bzw.
   beim Anzeigen ohnehin von Fomantic überschrieben.

   Der eigentliche Auslöser für das Überlaufen auf Tablets war die feste
   min-height der Detail-Modale (unten): sie zwang den Inhalt über die
   Fomantic-Scrollgrenze hinaus. Diese ist jetzt auf min(N, 60vh) gedeckelt.
   =========================================================================== */

/* Alle Modale mit Tabs: fixe Höhe, damit kein Springen beim Tab-Wechsel.
   min-height == max-height → Fenster bleibt immer gleich groß; Inhalt scrollt intern. */
#app-modal.modal-has-tabs > .scrolling.content,
#app-modal-2.modal-has-tabs > .scrolling.content {
    min-height: min(500px, 60vh);
    max-height: min(500px, 60vh);
}

/* HERO-19: Helden-Detail braucht mehr Platz (Skill-Baum).
   Überschreibt modal-has-tabs durch höhere Spezifität (gleiche ID + Klasse). */
#app-modal.modal-hero {
    width: 950px;
    max-width: 95vw;
}

#app-modal.modal-hero > .scrolling.content,
#app-modal-2.modal-hero > .scrolling.content {
    min-height: min(840px, 60vh);
    max-height: min(840px, 60vh);
}

/* Verwaltungs-Modal (ADV-19): fest 950 px breit. */
#app-modal.modal-event {
    width: 950px;
    max-width: 95vw;
}

#app-modal.modal-event > .scrolling.content {
    min-height: min(820px, 60vh);
    max-height: min(820px, 60vh);
}

/* UI-28: Auf Mobilgeräten fixed heights aufheben, damit Fomantics max-height greift
   und der Modal-Header nie über den Viewport-Rand wandert.
   dvh berücksichtigt kollabierte Adressleisten (iOS Safari, Chrome Android). */
@media (max-width: 767px) {
    #app-modal.modal-has-tabs > .scrolling.content,
    #app-modal-2.modal-has-tabs > .scrolling.content,
    #app-modal.modal-hero > .scrolling.content,
    #app-modal-2.modal-hero > .scrolling.content,
    #app-modal.modal-event > .scrolling.content {
        min-height: 0;
        max-height: calc(80dvh - 10rem);
    }
    #app-modal.modal-hero,
    #app-modal-2.modal-hero,
    #app-modal.modal-event {
        top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
}

/* Full-Page Adventure-Tabs: fixe Segmenthöhe, damit die weiße Karte nicht springt.
   Gilt nur für Vollseiten (show/manage) — in Modalen übernimmt .scrolling.content die Höhe. */
.adv-detail-page .ui.bottom.attached.tab.segment {
    min-height: min(460px, 58vh);
    max-height: min(460px, 58vh);
    overflow-y: auto;
}
.adv-manage-page .ui.bottom.attached.tab.segment {
    min-height: min(750px, 62vh);
    max-height: min(750px, 62vh);
    overflow-y: auto;
}
@media (max-width: 767px) {
    .adv-detail-page .ui.bottom.attached.tab.segment,
    .adv-manage-page .ui.bottom.attached.tab.segment {
        min-height: 0;
        max-height: none;
        overflow-y: visible;
    }
}

/* Positions-Editor (HERO-17): nummerierte, ziehbare Marker */
.editor-marker {
    font-size: 12px;
    font-weight: bold;
    line-height: 24px;
    text-align: center;
    color: #3b250f;
    touch-action: none;
    cursor: grab;
}

.editor-marker:active {
    cursor: grabbing;
}

/* Textliste unterhalb des Baums nur auf schmalen Ansichten (< 1100px) */
.skill-list {
    display: none;
}

@media (max-width: 1099px) {
    .skill-list {
        display: block;
    }
}

/* UI-11: Close-Button als <button> statt <i> – Fomantic-Styling beibehalten. */
.ui.modal > button.close.icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* UI-08: Modals auf Mobilgeräten vollbreit und mit kompakten Rändern. */
#app-modal,
#app-modal-2 {
    max-width: 95vw;
}

@media (max-width: 767px) {
    #app-modal,
    #app-modal-2 {
        width: 95vw !important;
        margin: 0.5rem auto !important;
    }
}

/* UI-26/UI-27: Modal-Footer beide Ebenen — Primäraktionen links, „Schließen" rechts. */
#app-modal-actions,
#app-modal-2-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
#app-modal-actions .deny,
#app-modal-2-actions .deny {
    margin-left: auto;
}

/* UI-26: Auf Mobilgeräten umbrechen Buttons vollbreit, kein margin-left-auto-Quetschen. */
@media (max-width: 767px) {
    #app-modal-actions,
    #app-modal-2-actions {
        flex-direction: column;
        align-items: stretch;
    }
    #app-modal-actions .deny,
    #app-modal-2-actions .deny {
        margin-left: 0;
    }
    #app-modal-actions .button,
    #app-modal-2-actions .button {
        min-height: 44px;
        justify-content: center;
    }
}

/* UI-44: #app-modal-2 als Bottom-Sheet auf < sm.
   Fomantic setzt top/margin via JS – alles mit !important überschreiben.
   Ab sm bleibt das Verhalten des zentrierten Modals unverändert. */
@media (max-width: 639px) {
    #app-modal-2 {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 92svh !important;
        margin: 0 !important;
        border-radius: 1rem 1rem 0 0 !important;
        overflow: hidden !important;
        animation: sheet-slide-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    }

    @keyframes sheet-slide-up {
        from { transform: translateY(50%); }
        to   { transform: translateY(0); }
    }

    /* Drag-Indikator-Pill oben */
    #app-modal-2::before {
        content: '';
        display: block;
        width: 2.5rem;
        height: 4px;
        background: rgba(90, 58, 34, 0.3);
        border-radius: 2px;
        margin: 0.625rem auto 0.25rem;
    }

    /* Schließen-Button ins Sheet verschieben (sonst durch overflow:hidden abgeschnitten) */
    #app-modal-2 > .close.icon {
        position: absolute !important;
        top: 0.625rem !important;
        right: 0.75rem !important;
        color: #5a3a22 !important;
        z-index: 10 !important;
    }

    #app-modal-2 > .header {
        border-radius: 0 !important;
    }

    /* Inhalt scrollt – Höhe minus Pill + Header + Footer */
    #app-modal-2 > .scrolling.content {
        max-height: calc(92svh - 11rem) !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
    }
}

/* ==========================================================================
   ARCH-003: Mobile-Primitive
   ========================================================================== */

/* --- UI-42: Bottom-Navigation ------------------------------------------- */
@media (max-width: 639px) {
    /* Basisabstand für Bottom-Nav (Höhe = 4rem = 64px) */
    #page-main {
        padding-bottom: 4rem;
    }

    /* Bottom-Nav-Items: Icon + Label, vertikal zentriert */
    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.125rem;
        min-width: 3rem;
        height: 100%;
        padding: 0 0.5rem;
        font-size: 0.65rem;
        line-height: 1;
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
}

/* --- Sticky-Aktions-Footer (Vollseiten, Mobile) -------------------------- */
@media (max-width: 639px) {
    .sticky-page-footer {
        position: fixed;
        bottom: 4rem; /* sitzt über der Bottom-Nav */
        left: 0;
        right: 0;
        z-index: 40;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        border-top: 2px solid rgba(90, 58, 34, 0.25);
        padding: 0.75rem 1rem;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    }
    body:has(.sticky-page-footer) #page-main {
        padding-bottom: 8.5rem; /* Bottom-Nav 4rem + Sticky-Footer ~4rem + Puffer */
    }
}

/* --- Accordion-Abschnitt (<details>/<summary>) --------------------------- */
.mobile-accordion-section summary::-webkit-details-marker { display: none; }
.mobile-accordion-section summary::marker { display: none; }
.mobile-accordion-section[open] .mobile-accordion-chevron {
    transform: rotate(180deg);
}

/* --- Tabelle → Karten auf Mobile ---------------------------------------- */
@media (max-width: 639px) {
    .mobile-cards-table-wrapper table thead { display: none; }
    .mobile-cards-table-wrapper table tbody tr {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        margin-bottom: 0.75rem;
        padding: 0.25rem 0.75rem;
        background: #fff;
    }
    .mobile-cards-table-wrapper table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.35rem 0;
        border: none !important;
    }
    .mobile-cards-table-wrapper table td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.7rem;
        color: #78716c;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        margin-right: 0.5rem;
    }
    /* Einzelzellen (leere Zeilen) nicht als Karte behandeln */
    .mobile-cards-table-wrapper table tbody tr td:only-child {
        display: table-cell;
    }
    /* Aktions-Zelle (kein data-label): Trenner + Buttons voll breit */
    .mobile-cards-table-wrapper table td:not([data-label]):not(:only-child) {
        border-top: 1px solid #e5e7eb !important;
        margin-top: 0.25rem;
        padding-top: 0.5rem;
    }
    .mobile-cards-table-wrapper table td:not([data-label]):not(:only-child) > div {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Fomantic-Dropdown auf select-Basis: Mindesthöhe damit Schrift nicht abgeschnitten wird. */
select.ui.dropdown {
    min-height: 39px;
}

/* ==========================================================================
   UI-45: Datensparmodus
   Aktiv wenn der Nutzer den manuellen Toggle gesetzt hat (data-save-data="1"
   am <body>) oder der Browser prefers-reduced-data signalisiert.
   Dekorative Hintergrundbilder werden ausgeblendet; funktionale Inhalte bleiben.
   ========================================================================== */

/* Dekorative Hintergrundbilder via CSS unterdrücken */
@media (prefers-reduced-data: reduce) {
    .bg-cover, .bg-center, [class*="bg-[url"] {
        background-image: none !important;
    }
}

body[data-save-data="1"] .bg-cover,
body[data-save-data="1"] .bg-center,
body[data-save-data="1"] [style*="background-image"] {
    background-image: none !important;
}

/* Dekoratives Poster (players/index) im Datenspar-Modus ausblenden */
body[data-save-data="1"] .save-data-hide {
    display: none !important;
}
