/**
 * Alacri Theme Engine Standard — Phase 5 (Default IPS / Cork City FC).
 * App-scoped styles. No native IPS or theme CSS is modified.
 *
 * Font-size contract: text size changes ONLY on actual reading content
 * (posts, replies, comments, articles, blogs, private messages) and on the
 * typing surface of the IPS 5 TipTap/ProseMirror editor. Navigation, headers,
 * footers, titles, usernames, dates, metadata, buttons, widgets, menus,
 * editor toolbars, forms and the accessibility controls are never resized.
 * Only the OUTERMOST content element is scaled; descendants inherit, so sizes
 * never compound.
 *
 * The size is  base x factor.  --ate-reader-base defaults to 1em (relative to
 * the parent, which is not scaled); a theme may set it to the content text's
 * own natural size (e.g. 1rem) so that 100% is exactly the theme's size.
 */
html[data-ate-mode] {
    --ate-surface: var(--i-box--ba-co, var(--i-background_1, #fff));
    --ate-text: var(--i-color_root, currentColor);
    --ate-soft-text: var(--i-color_soft, currentColor);
    --ate-border: var(--i-box--bo-co, #777);
    --ate-accent: var(--i-primary, #087752);
    --ate-accent-text: var(--i-primary-button--co, #fff);
    --ate-focus: var(--i-primary, #087752);
}

/* ---------------------------------------------------------------------------
   Controls (shared by the toolkit panel and the Content Preferences page)
   ------------------------------------------------------------------------- */
.ateControls { display:block; font-size:.94rem; line-height:1.45; color:var(--ate-text); }
.ateControls__section { display:grid; gap:.45rem; padding-top:.85rem; }
.ateControls__section h3 { margin:0; font-size:.85rem; font-weight:750; color:var(--ate-soft-text); }
.ateControls__note { font-size:.8rem; line-height:1.4; color:var(--ate-soft-text); }
.ateControls__size { display:flex; gap:.4rem; flex-wrap:wrap; }
.ateControls__button {
    min-height:44px; min-width:44px; padding:.45rem .8rem; font:inherit; cursor:pointer;
    border:1px solid var(--ate-border); border-radius:7px; color:var(--ate-text); background:var(--ate-surface);
}
.ateControls__button:hover:not(:disabled) { border-color:var(--ate-accent); }
.ateControls__button[aria-pressed="true"] { border-color:var(--ate-accent); box-shadow:inset 0 0 0 1px var(--ate-accent); }
.ateControls__button:disabled { cursor:not-allowed; opacity:.5; }
.ateControls__sizeStatus { font-size:.82rem; }
.ateControls__check { display:flex; align-items:center; gap:.6rem; margin:0; padding:.3rem 0; cursor:pointer; min-height:36px; }
.ateControls__check input { width:1.1rem; height:1.1rem; flex:0 0 auto; accent-color:var(--ate-accent); }
.ateControls__check input:disabled + span { opacity:.55; }
.ateControls__check input:disabled { cursor:not-allowed; }
.ateControls__reset { width:100%; margin-top:1rem; }
.ateControls :focus-visible { outline:3px solid var(--ate-focus); outline-offset:3px; }

/* ---------------------------------------------------------------------------
   Floating accessibility button + panel. Always position:fixed on <body>:
   it never sits in, or enlarges, the footer. Colours come from the active
   theme's own IPS variables, so it matches each theme.
   ------------------------------------------------------------------------- */
html[data-ate-mode] .ateToolkit {
    position:fixed; z-index:900; margin:0; isolation:isolate;
    bottom:max(var(--ate-floating-clearance, 16px), calc(16px + env(safe-area-inset-bottom, 0px)));
    inset-inline-start:max(var(--ate-floating-offset, 16px), env(safe-area-inset-left, 0px));
    font-size:.94rem; line-height:1.45; color:var(--ate-text);
    transition:bottom .2s ease;
}
@media (prefers-reduced-motion:reduce) { html[data-ate-mode] .ateToolkit { transition:none; } }
html.atePref--reduceMotion .ateToolkit { transition:none !important; }
html[data-ate-mode] .ateToolkit[data-ate-floating="right"] {
    inset-inline-start:auto;
    inset-inline-end:max(var(--ate-floating-offset, 16px), env(safe-area-inset-right, 0px));
}
html[data-ate-mode] .ateToolkit [hidden] { display:none !important; }
html[data-ate-mode] .ateToolkit button { font:inherit; cursor:pointer; }
html[data-ate-mode] .ateToolkit__launcher {
    display:inline-flex; align-items:center; justify-content:center;
    width:44px; height:44px; padding:0; border-radius:50%;
    font-size:1.15rem; line-height:1;
    color:var(--i-color_hard, var(--ate-text));
    background:var(--i-box--ba-co, var(--ate-surface));
    border:1px solid var(--i-box--bo-co, var(--ate-border));
    box-shadow:0 6px 20px rgba(0,0,0,.28);
    transition:border-color .15s ease, transform .15s ease;
}
html[data-ate-mode] .ateToolkit__launcher:hover,
html[data-ate-mode] .ateToolkit__launcher[aria-expanded="true"] { border-color:var(--ate-accent); }
html[data-ate-mode] .ateToolkit__launcher:active { transform:scale(.96); }
html[data-ate-mode] .ateToolkit__panel {
    position:absolute; bottom:calc(100% + .75rem); inset-inline-start:0;
    width:min(22rem, calc(100vw - 24px)); max-height:min(75vh, 42rem);
    overflow-y:auto; overscroll-behavior:contain; box-sizing:border-box; padding:1.1rem 1.25rem 1.25rem;
    border:1px solid var(--i-box--bo-co, var(--ate-border)); border-radius:14px;
    background:var(--i-box--ba-co, var(--ate-surface)); color:var(--i-color_root, var(--ate-text));
    box-shadow:0 18px 45px rgba(0,0,0,.35); text-align:start;
    scrollbar-width:thin; scrollbar-color:var(--i-color_soft, #888) transparent;
}
html[data-ate-mode] .ateToolkit[data-ate-floating="right"] .ateToolkit__panel { inset-inline-start:auto; inset-inline-end:0; }
html[data-ate-mode] .ateToolkit[data-ate-placement="below"] .ateToolkit__panel { top:calc(100% + .75rem); bottom:auto; }
html[data-ate-mode] .ateToolkit__head {
    display:flex; justify-content:space-between; gap:.75rem; align-items:center;
    padding-bottom:.8rem; margin-bottom:.35rem; border-bottom:1px solid var(--i-box--bo-co, var(--ate-border));
}
html[data-ate-mode] .ateToolkit__head strong { font-size:1.15rem; font-weight:750; color:var(--i-color_hard, inherit); }
/* The × is drawn with two centred bars rather than a text glyph, whose
   position varies with the theme font, so it is always exactly centred. */
html[data-ate-mode] .ateToolkit__close {
    position:relative; display:inline-flex; align-items:center; justify-content:center;
    box-sizing:border-box; width:40px; height:40px; flex:0 0 40px; padding:0 !important; margin:0;
    font-size:0 !important; line-height:0; color:inherit;
    border:1px solid transparent; border-radius:.5rem; background:transparent;
}
html[data-ate-mode] .ateToolkit__close::before,
html[data-ate-mode] .ateToolkit__close::after {
    content:""; position:absolute; top:50%; left:50%;
    width:18px; height:2px; margin:-1px 0 0 -9px; border-radius:1px;
    background:currentColor; transform:rotate(45deg);
}
html[data-ate-mode] .ateToolkit__close::after { transform:rotate(-45deg); }
@media (forced-colors:active) {
    html[data-ate-mode] .ateToolkit__close::before,
    html[data-ate-mode] .ateToolkit__close::after { background:CanvasText; }
}
html[data-ate-mode] .ateToolkit__close:hover { border-color:var(--i-box--bo-co, var(--ate-border)); }
html[data-ate-mode] .ateToolkit__mode {
    display:flex; align-items:center; gap:.65rem; min-height:44px; margin:.35rem 0 0; cursor:pointer; font-weight:700;
}
html[data-ate-mode] .ateToolkit__mode input { width:1.15rem; height:1.15rem; flex:0 0 auto; accent-color:var(--ate-accent); }
html[data-ate-mode] .ateToolkit__status { margin:0; min-height:1.2em; font-size:.8rem; color:var(--ate-soft-text); }
html[data-ate-mode] .ateToolkit__status[data-ate-status="error"] { color:#cf3535; }
html[data-ate-mode] .ateToolkit .ateControls__section h3 {
    font-size:.78rem; font-weight:800; letter-spacing:.09em; text-transform:uppercase; color:var(--i-color_hard, inherit);
}
html[data-ate-mode] .ateToolkit .ateControls__check { font-size:1rem; }
html[data-ate-mode] .ateToolkit .ateControls__button { min-width:3rem; min-height:2.6rem; border-radius:.55rem; }
html[data-ate-mode] .ateToolkit :focus-visible { outline:3px solid var(--ate-focus) !important; outline-offset:3px !important; }

html[data-ate-mode="on"].atePref--contrast :is(.ipsEditor, .ipsEditor__toolbar, input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"]), select, textarea):not(.ipsButton) {
    color:var(--ate-hc-text) !important;
}

/* ---------------------------------------------------------------------------
   Reading / typing text size (see the font-size contract above).
   IPS 5 sizes member content with --set__i-user-content-font-size (a
   percentage) on .ipsRichText--user and on the TipTap/ProseMirror surface;
   the engine multiplies that same base, so 100% is exactly the theme's size.
   Only the outermost content element is scaled, so sizes never compound.
   ------------------------------------------------------------------------- */
html[data-ate-mode="on"] {
    --ate-reader-factor:1;
    --ate-reader-natural:calc(var(--set__i-user-content-font-size, 100) * .01em);
}
html[data-ate-mode="on"][data-ate-reader-size="-2"] { --ate-reader-factor:.88; }
html[data-ate-mode="on"][data-ate-reader-size="-1"] { --ate-reader-factor:.94; }
html[data-ate-mode="on"][data-ate-reader-size="1"]  { --ate-reader-factor:1.1; }
html[data-ate-mode="on"][data-ate-reader-size="2"]  { --ate-reader-factor:1.2; }
html[data-ate-mode="on"][data-ate-reader-size="3"]  { --ate-reader-factor:1.32; }

html[data-ate-mode="on"]:not([data-ate-reader-size="0"]) :is(.ipsRichText--user, [data-role="commentContent"]):not(:has(.ipsEditor)):not(:is(.ipsRichText--user, [data-role="commentContent"], .ProseMirror) *) {
    font-size:calc(var(--ate-reader-base, var(--ate-reader-natural)) * var(--ate-reader-factor)) !important;
}
html[data-ate-mode="on"]:not([data-ate-reader-size="0"]) .ProseMirror {
    font-size:max(16px, calc(var(--ate-reader-base, var(--ate-reader-natural)) * var(--ate-reader-factor))) !important;
}

/* ---------------------------------------------------------------------------
   Display options (only while Accessibility Mode is on).
   ------------------------------------------------------------------------- */
/* High contrast: soft and body text use the theme's own strongest text colour. */
html[data-ate-mode="on"].atePref--contrast,
html[data-ate-mode="on"].atePref--contrast[data-ips-scheme] {
    --ate-hc-text:var(--i-color_hard, CanvasText);
    --i-color_root:var(--i-color_hard);
    --i-color_soft:var(--i-color_hard);
}
html[data-ate-mode="on"].atePref--contrast :is(.ipsRichText--user, [data-role="commentContent"], .ProseMirror) {
    color:var(--ate-hc-text) !important;
}
html[data-ate-mode="on"].atePref--contrast :is(.ipsRichText--user, [data-role="commentContent"]) a {
    text-decoration:underline !important;
}

/* Line spacing: reading content and the typing surface. */
html[data-ate-mode="on"].atePref--lineSpacing :is(.ipsRichText--user, [data-role="commentContent"], .ProseMirror),
html[data-ate-mode="on"].atePref--lineSpacing :is(.ipsRichText--user, [data-role="commentContent"], .ProseMirror) :is(p, li, blockquote, td, th, div) {
    line-height:2.1 !important;
}
html[data-ate-mode="on"].atePref--lineSpacing :is(.ipsRichText--user, [data-role="commentContent"], .ProseMirror) p {
    margin-block-end:1em;
}

/* Readable font: swaps the theme's base font family (icons keep their own). */
html[data-ate-mode="on"].atePref--readableFont,
html[data-ate-mode="on"].atePref--readableFont[data-ips-scheme] {
    --i-font-family:"Atkinson Hyperlegible", Verdana, Tahoma, "Segoe UI", system-ui, sans-serif;
}
html[data-ate-mode="on"].atePref--readableFont :is(body, .ipsRichText--user, [data-role="commentContent"], .ProseMirror, input, textarea, select) {
    font-family:"Atkinson Hyperlegible", Verdana, Tahoma, "Segoe UI", system-ui, sans-serif !important;
    letter-spacing:.01em;
}

/* Underline links: text links in content, page body and footer, not buttons, tabs or icon links. */
html[data-ate-mode="on"].atePref--underlineLinks :is(.ipsRichText, .ipsLayout__main, main, .ipsFooter, .ipsBreadcrumb) a[href]:not([class*="ipsButton"], [role="button"], [role="tab"], .ipsUserPhoto, :has(> img:only-child)) {
    text-decoration:underline !important;
    text-underline-offset:.18em;
    text-decoration-thickness:max(1px, .07em);
}

/* Reduce motion. */
html[data-ate-mode="on"].atePref--reduceMotion { scroll-behavior:auto !important; }
html[data-ate-mode="on"].atePref--reduceMotion *,
html[data-ate-mode="on"].atePref--reduceMotion *::before,
html[data-ate-mode="on"].atePref--reduceMotion *::after {
    animation-duration:.001ms !important; animation-iteration-count:1 !important;
    transition-duration:.001ms !important; transition-delay:0s !important; scroll-behavior:auto !important;
}

/* Reduce visual effects: shadows, blurs and glows. */
html[data-ate-mode="on"].atePref--reduceEffects *:not(.ateToolkit__panel, .ateToolkit__launcher),
html[data-ate-mode="on"].atePref--reduceEffects *::before,
html[data-ate-mode="on"].atePref--reduceEffects *::after {
    box-shadow:none !important; text-shadow:none !important;
    backdrop-filter:none !important; -webkit-backdrop-filter:none !important;
}

/* Stronger focus outlines. */
html[data-ate-mode="on"].atePref--focusStrong :focus-visible {
    outline:3px solid var(--ate-focus) !important; outline-offset:3px !important;
    box-shadow:0 0 0 6px color-mix(in srgb, var(--ate-focus) 30%, transparent) !important;
}

@media (max-width:979px) {
    /* Phones: a smaller, less intrusive button that still meets the 40px+ touch-target size. */
    html[data-ate-mode] .ateToolkit__launcher { width:40px; height:40px; font-size:1.05rem; box-shadow:0 3px 12px rgba(0,0,0,.25); }
    html[data-ate-mode] .ateToolkit__panel { width:min(22rem, calc(100vw - 20px)); max-height:min(70dvh, 36rem); }
}
@media (forced-colors:active) {
    html[data-ate-mode] .ateToolkit__panel, html[data-ate-mode] .ateToolkit__launcher { border:1px solid CanvasText; color:CanvasText; background:Canvas; }
    .ateControls__button { border-color:ButtonText; }
}

/* ---------------------------------------------------------------------------
   Content Preferences section (visible whatever the Accessibility Mode state)
   ------------------------------------------------------------------------- */
html .ateContentPreference {
    padding: clamp(.9rem, 2vw, 1.3rem); margin: 1rem;
    border: 1px solid var(--i-box--bo-co, #777); border-radius: .6rem;
    background: var(--i-box--ba-co, var(--i-background_1, #fff)); color: var(--i-color_root, inherit);
}
html .ateContentPreference h3 { margin:0 0 .7rem; font-size:1.1rem; font-weight:700; }
html .ateContentPreference .ateControls__section h3 { margin:0; font-size:.9rem; }
html .ateContentPreference__switch {
    display:flex; align-items:center; gap:.7rem; cursor:pointer; min-height:44px; max-width:max-content;
}
html .ateContentPreference__switch input {
    flex:0 0 auto; width:1.25rem; height:1.25rem; accent-color:var(--i-primary, #087752);
}
html .ateContentPreference__switch:focus-within {
    outline:2px solid var(--i-primary, currentColor); outline-offset:3px; border-radius:3px;
}
html .ateContentPreference p { margin:.35rem 0; opacity:.88; }
html .ateContentPreference__status { min-height:1.4em; font-size:.87rem; }
html .ateContentPreference__status[data-ate-status="error"] { color:#cf3535; opacity:1; }
html .ateContentPreference .ateControls {
    margin-top:.5rem; padding-top:.15rem; border-top:1px solid var(--i-box--bo-co, #777);
}
@media(forced-colors:active) {
    html .ateContentPreference { border-color:CanvasText; background:Canvas; color:CanvasText; }
}

/* Settings row inside the Content Preferences form, above Save. */
html .ateContentPreferenceRow { display:block; padding-top:0; }
html .ateContentPreferenceRow .ateContentPreference { margin:0; }

/* When a theme supplies its own toolkit, it follows the member's engine-level switch. */
html[data-ate-mode="off"] .echoMistToolkit { display: none !important; }
