/* CS-301: SOMETHING WENT WRONG (#crash-panel in index.html, opened by js/error-panel.js only when the game
   has stopped for good). The in-game kit dialog drawn in HTML, because Unity can no longer draw:
   UiKitDialog's chrome (Assets/Scripts/UI/Kit/UiKitDialog.cs: chamfered hairline frame, Screen fill, Deep
   header with crest box, red "/" + Oswald caps title, 2px red mark at the top-left) and ConnectionErrorPanel's
   body + button row (Assets/Scripts/UI/ConnectionErrorPanel.cs: width 540 / 430, row top 18 / 13, gap 12 / 8,
   phone portrait stacked with the primary on top), on ui-kit.css's .mmo-ui-kit colour tokens and fonts.
   RELOAD = Button.Primary (lime, .kit-primary), SUPPORT = Button.Secondary (chamfered hairline frame).

   Every size is a custom property below, per breakpoint, on UiKitBreakpoints.Classify's rule (width <= 600 =
   phone portrait, else height <= 500 = phone landscape, else desktop). Type sizes are UiKitTokens' DialogTitle /
   DialogBody / DialogHelper / DialogBtnPrimary / DialogBtnSecondary. Buttons are 44 tall on phones (the HTML
   kit's touch floor, ui-kit.css .kit-button) where the in-game row uses 34.
   Tools/LayoutChecks/crash-panel-check.js READS these properties, lays the panel out at the 9 QA sizes with the
   real copy from index.html and the real font files, and FAILs when anything does not fit: change them together. */

#crash-panel {
    --crash-w: 540px;              /* ConnectionErrorPanel.WidthDesktopCss (phones: WidthPhoneCss 430) */
    --crash-margin: 12px;          /* UiKitDialog.ViewportMarginCss 24 = 12 a side */
    --crash-cap: 0.92;             /* UiKitDialog.CapOfSafeHeight: at most 92% of the viewport height */
    --crash-cut: 14px;             /* UiKitDialog panel cut 14 / 10 */
    --crash-head-h: 64px;          /* UiKitDialog header 64 / 44 */
    --crash-head-pad-l: 18px;      /* 18 / 12 */
    --crash-head-pad-r: 14px;      /* 14 / 8 */
    --crash-head-gap: 12px;        /* crest -> slash, 12 / 8 */
    --crash-slash-gap: 9px;        /* slash -> title, 9 / 8 */
    --crash-crest: 42px;           /* crest box 42 / 30 */
    --crash-crest-icon: 28px;      /* crest icon 28 / 20 */
    --crash-crest-cut: 7px;        /* UiKitDialog.CrestCutCss */
    --crash-red-w: 120px;          /* red mark 120 / 80, 2 tall */
    --crash-title: 24px;           /* DialogTitle 24 / 18 / 17, Oswald 700, ls .8 */
    --crash-pad-t: 18px;           /* body padding 18 20 20 / 10 12 12 */
    --crash-pad-x: 20px;
    --crash-pad-b: 20px;
    --crash-body: 16px;            /* DialogBody 16 / 13 / 11, Barlow 400 */
    --crash-helper: 12.5px;        /* DialogHelper 12.5 / 11 / 9.5, Barlow 400, muted */
    --crash-row-gap: 12px;         /* body row gap 12 / 7 */
    --crash-btn-top: 18px;         /* button row top 18 / 13 */
    --crash-btn-h: 52px;           /* 52 desktop; 44 on phones (touch floor) */
    --crash-btn-gap: 12px;         /* 12 / 8 */
    --crash-btn-pad-x: 12px;       /* label inset inside a button */
    --crash-btn-cut: 8px;          /* UiKitTokens.CutButton */
    --crash-btn1: 19px;            /* DialogBtnPrimary 19 / 15 / 14, Oswald 700, ls 1.5 */
    --crash-btn2: 17px;            /* DialogBtnSecondary 17 / 14 / 14, ls 1.4 */

    position: fixed;
    inset: 0;
    /* Above every page layer (loading screen 1, game frame 10, chrome 15, page buttons 20, leave dialog 30,
       login / cashier 40, country block 45, reload guard 9998) and level with the iOS toast, which comes
       earlier in the DOM and which error-panel.js hides anyway. Only #rotate-message (10000) is higher: in
       portrait the whole #unity-container is hidden behind it. */
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding:
        max(var(--crash-margin), env(safe-area-inset-top, 0px))
        max(var(--crash-margin), env(safe-area-inset-right, 0px))
        max(var(--crash-margin), env(safe-area-inset-bottom, 0px))
        max(var(--crash-margin), env(safe-area-inset-left, 0px));
    background: rgba(6, 10, 14, 0.72);   /* UiKitDialog.ScrimColor */
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 600px) {
    #crash-panel {
        --crash-w: 430px;
        --crash-cut: 10px;
        --crash-head-h: 44px;
        --crash-head-pad-l: 12px;
        --crash-head-pad-r: 8px;
        --crash-head-gap: 8px;
        --crash-slash-gap: 8px;
        --crash-crest: 30px;
        --crash-crest-icon: 20px;
        --crash-red-w: 80px;
        --crash-title: 18px;
        --crash-pad-t: 10px;
        --crash-pad-x: 12px;
        --crash-pad-b: 12px;
        --crash-body: 13px;
        --crash-helper: 11px;
        --crash-row-gap: 7px;
        --crash-btn-top: 13px;
        --crash-btn-h: 44px;
        --crash-btn-gap: 8px;
        --crash-btn1: 15px;
        --crash-btn2: 14px;
    }
}

@media (max-height: 500px) and (min-width: 601px) {
    #crash-panel {
        --crash-w: 430px;
        --crash-cut: 10px;
        --crash-head-h: 44px;
        --crash-head-pad-l: 12px;
        --crash-head-pad-r: 8px;
        --crash-head-gap: 8px;
        --crash-slash-gap: 8px;
        --crash-crest: 30px;
        --crash-crest-icon: 20px;
        --crash-red-w: 80px;
        --crash-title: 17px;
        --crash-pad-t: 10px;
        --crash-pad-x: 12px;
        --crash-pad-b: 12px;
        --crash-body: 11px;
        --crash-helper: 9.5px;
        --crash-row-gap: 7px;
        --crash-btn-top: 13px;
        --crash-btn-h: 44px;
        --crash-btn-gap: 8px;
        --crash-btn1: 14px;
        --crash-btn2: 14px;
    }
}

#crash-panel.visible {
    display: flex;
}

/* Frame: the 1px hairline is the sheet's own background showing around the fill (UiKitDialog "Frame" +
   "Fill" inset 1px), both chamfered top-right and bottom-left. */
#crash-panel-sheet {
    position: relative;
    display: flex;
    width: min(var(--crash-w), 100%);
    max-height: min(100%, calc(var(--crash-cap) * 100vh));
    max-height: min(100%, calc(var(--crash-cap) * 100dvh));
    padding: 1px;
    background: var(--kit-line);
    clip-path: polygon(0 0, calc(100% - var(--crash-cut)) 0, 100% var(--crash-cut), 100% 100%, var(--crash-cut) 100%, 0 calc(100% - var(--crash-cut)));
}

/* The 2px red mark at the panel's top-left, drawn over the header (UiKitDialog "RedLine"). */
#crash-panel-sheet::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: var(--crash-red-w);
    height: 2px;
    background: var(--kit-red);
}

#crash-panel-fill {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--kit-screen);
    clip-path: polygon(0 0, calc(100% - (var(--crash-cut) - 0.6px)) 0, 100% calc(var(--crash-cut) - 0.6px), 100% 100%, calc(var(--crash-cut) - 0.6px) 100%, 0 calc(100% - (var(--crash-cut) - 0.6px)));
}

#crash-panel-top {
    flex: none;
    display: flex;
    align-items: center;
    height: var(--crash-head-h);
    padding: 0 var(--crash-head-pad-r) 0 var(--crash-head-pad-l);
    background: var(--kit-deep);
    border-bottom: 1px solid var(--kit-line);
}

#crash-panel-crest {
    flex: none;
    width: var(--crash-crest);
    height: var(--crash-crest);
    margin-right: var(--crash-head-gap);
    padding: 1px;
    background: var(--kit-line);
    clip-path: polygon(0 0, calc(100% - var(--crash-crest-cut)) 0, 100% var(--crash-crest-cut), 100% 100%, var(--crash-crest-cut) 100%, 0 calc(100% - var(--crash-crest-cut)));
}

#crash-panel-crest-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--kit-deep);
    color: var(--kit-teal);
    clip-path: polygon(0 0, calc(100% - (var(--crash-crest-cut) - 0.6px)) 0, 100% calc(var(--crash-crest-cut) - 0.6px), 100% 100%, calc(var(--crash-crest-cut) - 0.6px) 100%, 0 calc(100% - (var(--crash-crest-cut) - 0.6px)));
}

#crash-panel-crest .picto {
    width: var(--crash-crest-icon);
    height: var(--crash-crest-icon);
}

/* Picto glyph (style.css .picto): url() resolves next to this sheet, at the template root. */
.picto-mark-question { --picto: url("TemplateData/icons/PictoIcon_Mark_Question.png"); }

#crash-panel-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font: 700 var(--crash-title)/1.482 'Kit Oswald', 'Arial Narrow', sans-serif;   /* OswaldLineHeight */
    letter-spacing: 0.8px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--kit-ink);
}

/* The kit's red slash before a dialog title (UiKitDialog "Slash", UiKitTokens.Mag). */
#crash-panel-title::before {
    content: "/";
    margin-right: var(--crash-slash-gap);
    color: var(--kit-red);
}

/* Only a body taller than the 92% cap scrolls (UiKitDialog.FitHeight); the layout check keeps every QA
   size below the cap. */
#crash-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: var(--crash-pad-t) var(--crash-pad-x) var(--crash-pad-b);
}

#crash-panel-text {
    margin: 0;
    font: 400 var(--crash-body)/1.2 'Kit Barlow', sans-serif;   /* BarlowLineHeight */
    color: var(--kit-ink);
}

#crash-panel-report {
    margin: var(--crash-row-gap) 0 0;
    font: 400 var(--crash-helper)/1.2 'Kit Barlow', sans-serif;
    color: var(--kit-muted);
}

#crash-panel-actions {
    display: flex;
    gap: var(--crash-btn-gap);
    margin-top: var(--crash-btn-top);
}

/* Equal halves, RELOAD (primary) first: left on desktop and landscape, on top in portrait. */
#crash-panel-actions .kit-button {
    flex: 1 1 0;
    min-width: 0;
    height: var(--crash-btn-h);
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--crash-btn-pad-x);
    white-space: nowrap;
    text-decoration: none;
}

@media (max-width: 600px) {
    #crash-panel-actions {
        flex-direction: column;
    }

    #crash-panel-actions .kit-button {
        flex: none;
        width: 100%;
    }
}

#crash-panel-reload {
    font-size: var(--crash-btn1);
    letter-spacing: 1.5px;
}

/* Button.Secondary: hairline-strong frame + Secondary fill, chamfered like every kit button. */
#crash-panel-support {
    position: relative;
    isolation: isolate;
    border: 0;
    background: var(--kit-line-strong);
    color: var(--kit-ink);
    font-size: var(--crash-btn2);
    letter-spacing: 1.4px;
    clip-path: polygon(0 0, calc(100% - var(--crash-btn-cut)) 0, 100% var(--crash-btn-cut), 100% 100%, var(--crash-btn-cut) 100%, 0 calc(100% - var(--crash-btn-cut)));
}

#crash-panel-support::before {
    content: "";
    position: absolute;
    inset: 1px;
    z-index: -1;
    background: var(--kit-secondary);
    clip-path: polygon(0 0, calc(100% - (var(--crash-btn-cut) - 0.6px)) 0, 100% calc(var(--crash-btn-cut) - 0.6px), 100% 100%, calc(var(--crash-btn-cut) - 0.6px) 100%, 0 calc(100% - (var(--crash-btn-cut) - 0.6px)));
}

#crash-panel-support:hover {
    background: var(--kit-ink);
}

#crash-panel-support:hover::before {
    background: var(--kit-panel);
}

#crash-panel-support:active {
    transform: translateY(1px);
}

#crash-panel-support:focus-visible {
    outline: 2px solid var(--kit-teal);
    outline-offset: -3px;
}
