/* Suite Talk — Interactive Panels (frontend structural CSS).
 * Per-instance colours/sizes are emitted as scoped inline CSS by FrontEnd.php
 * (selector `.suite-ip-{component_id}`) — this file only ever contains
 * structural rules shared by every component instance. */

.suite-ip-root,
.suite-ip-root * ,
.suite-ip-root *::before,
.suite-ip-root *::after {
    box-sizing: border-box;
}

.suite-ip-root {
    position: relative;
    width: 100%;
}

/* ── Tab bar (mobile/tablet navigation) — hidden until JS enables tab mode.
 * Default ("grid") layout is a compact, fixed-column grid — the column count
 * (--ip-tab-columns, set in FrontEnd.php from the panel count: one column
 * per panel up to 3, a 2-column wrapped grid for 4+) means every tab always
 * gets an equal, predictable share of the row with NO horizontal scrolling
 * and no per-tab width surprises (a flex row sized from each tab's natural
 * text width is what caused tabs to wrap one-per-line in an earlier attempt
 * at this — grid sidesteps that entirely). "Stack"
 * (data-ip-mobile-tab-layout="stack") collapses to a single column, each tab
 * its own full-width row, for anyone who still wants that presentation. ── */
.suite-ip-tabbar {
    display: grid;
    grid-template-columns: repeat(var(--ip-tab-columns, 3), minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
}
.suite-ip-tabbar[hidden] { display: none; }
.suite-ip-root[data-ip-mobile-tab-layout="stack"] .suite-ip-tabbar {
    grid-template-columns: 1fr;
}

.suite-ip-tab {
    min-width: 0;
    width: 100%;
    min-height: var(--ip-tab-min-height, 44px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font: inherit;
    line-height: 1.25;
    text-align: center;
    margin: 0;
    /* Divider colour/width (reusing the desktop separator token) and text
     * alignment are emitted per-instance in FrontEnd.php::component_css() —
     * this is only a structural fallback. */
    border-right: 0;
}
.suite-ip-tab:last-child { border-right: 0; }
/* !important is required here too — the generic theme-override reset below
 * (`.suite-ip-tab{border:0!important}`) zeroes every border side including
 * this one otherwise. */
.suite-ip-root[data-ip-mobile-tab-layout="stack"] .suite-ip-tab {
    border-right: 0 !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}
.suite-ip-root[data-ip-mobile-tab-layout="stack"] .suite-ip-tab:last-child { border-bottom: 0 !important; }
/* Whole-word wrapping up to two lines — never letter-split, never a third
 * line — so a one-line title still reserves the same tab height as a
 * two-line neighbour (see --ip-tab-min-height above). */
.suite-ip-tab .suite-ip-panel__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    width: 100%;
}
.suite-ip-tab:focus-visible { outline: none; }
/* Never reset focus with a bare `outline: ... currentColor` here — the real,
 * configurable focus treatment (colour/width/inset-vs-outline, or fully
 * disabled) is always emitted per-component in FrontEnd.php::component_css()
 * from the focus_enabled/focus_color/focus_width/focus_style settings. This
 * rule only suppresses the browser's own default focus ring so unstyled/raw
 * markup (e.g. a template preview with no generated CSS) never shows one. */

/* ── Panels — no-JS fallback: a simple stacked, fully-accessible layout ── */
.suite-ip-panels {
    display: flex;
    flex-direction: column;
    width: 100%;
}
.suite-ip-panel { width: 100%; }

.suite-ip-panel__header {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    text-align: left;
    background: none;
    cursor: pointer;
    font: inherit;
    margin: 0;
}
.suite-ip-panel__header:focus-visible { outline: none; }

/* Themes/page builders (e.g. Kubio's generated global styles) ship a generic
 * `[data-kubio] button` rule whose specificity (an attribute selector + a
 * type selector) beats a bare `.suite-ip-panel__header`/`.suite-ip-tab`
 * class selector, so a plain (non-!important) `border:0`/`appearance:none`
 * here is silently overridden on the real frontend — confirmed via computed
 * styles on the live site, where the theme's accent-coloured 2px border and
 * 4px border-radius were winning. This component owns its own button
 * chrome, so these specific properties are forced with !important; anything
 * the admin can actually configure (background colour, padding, etc.) is
 * deliberately left out of this list so FrontEnd.php::component_css() keeps
 * full, un-overridden control over it. Explicit `:hover`/`:focus`/`:active`
 * variants are included too — a theme `button:hover{border:...!important}`
 * rule still carries a pseudo-class, so it's only beaten here if our own
 * reset is *also* scoped to that same state rather than the plain base
 * selector alone. Actual hover/active background+text colours (from the
 * Hover background/Hover text colour settings) are emitted per-instance in
 * component_css(), always with !important, for the same reason. */
.suite-ip-tab,
.suite-ip-panel__header,
.suite-ip-tab:hover,
.suite-ip-tab:focus,
.suite-ip-tab:active,
.suite-ip-panel__header:hover,
.suite-ip-panel__header:focus,
.suite-ip-panel__header:active {
    appearance: none !important;
    -webkit-appearance: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Long titles/text must wrap within whatever width a panel is given instead
 * of forcing the flex row wider than its container (the classic flex-item
 * min-content overflow trap) — but ONLY at whole-word boundaries. Never use
 * `overflow-wrap: anywhere`/`break-word`/`word-break: break-all` here: those
 * let the browser split an ordinary word between individual letters
 * ("Unexplaine" / "d") whenever a line is tight, which is never acceptable
 * for real sentence content. `min-width: 0` alone is enough to let these flex
 * descendants shrink below their content's min-content width; normal
 * whitespace-based wrapping (the browser default) takes care of the rest. */
.suite-ip-panel__title,
.suite-ip-content-text,
.suite-ip-content-rich,
.suite-ip-list-text-wrap,
.suite-ip-preview-content,
.suite-ip-preview-text,
.suite-ip-list-note {
    min-width: 0;
}

.suite-ip-panel__body { width: 100%; min-width: 0; overflow-x: hidden; overflow-y: auto; }
/* True no-JS fallback only — once JS has initialised (.ip-js), visibility is
 * governed entirely by the mode-aware rules below instead. */
.suite-ip-panel__body[hidden] { display: none; }

/* ── JS-enhanced desktop expanding mode ── */
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panels {
    flex-direction: row;
    align-items: stretch;
    overflow: hidden;
}
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* Percentage mode — every panel takes a proportional share of the row,
 * computed server/JS-side into the --ip-basis custom property (legacy
 * behaviour, kept for anyone who prefers fixed proportions). */
.suite-ip-root.ip-js.ip-mode-expand[data-ip-width-mode="percentage"] .suite-ip-panel {
    flex: 0 0 var(--ip-basis, 33%);
}
/* Flexible mode (default) — the active panel fills the remaining space while
 * every inactive panel keeps a fixed, readable width so its preview content
 * has room to breathe. */
.suite-ip-root.ip-js.ip-mode-expand[data-ip-width-mode="flex"] .suite-ip-panel {
    flex: 0 0 var(--ip-inactive-width, 220px);
    min-width: var(--ip-inactive-min, 76px);
    max-width: var(--ip-inactive-max, 420px);
}
.suite-ip-root.ip-js.ip-mode-expand[data-ip-width-mode="flex"] .suite-ip-panel.is-active {
    flex: 1 1 0%;
    max-width: none;
}
.suite-ip-root.ip-js.ip-mode-expand:not(.ip-no-animate) .suite-ip-panel {
    transition: flex-basis var(--ip-duration, 380ms) var(--ip-easing, ease), flex-grow var(--ip-duration, 380ms) var(--ip-easing, ease);
}
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel__body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    /* Keeps every panel's body — active and inactive alike — the same
     * height, so the whole row (align-items:stretch above) is always as
     * tall as the tallest requirement across every panel arrangement
     * (tallest full content at the active width, or tallest preview at the
     * inactive width), regardless of which panel is currently open. Set in
     * JS (frontend.js::recalcLayout) from an off-flow measurement of every
     * panel in both states; falls back to 0 (no-op) before JS has measured
     * anything, e.g. for a split second on first paint. Because this value
     * already accounts for every arrangement, it never needs to change (or
     * be clamped) when the active panel changes — only a genuine viewport/
     * breakpoint change recalculates it. */
    min-height: var(--ip-content-height, 0);
}
/* Off-flow sandbox used only to measure a panel's full-content height at the
 * active panel's width without ever becoming visible or affecting layout. */
.suite-ip-measure {
    position: absolute;
    top: 0;
    left: -99999px;
    visibility: hidden;
    pointer-events: none;
}

/* Full content / preview content swap (desktop/expand mode only). Only ONE of
 * these is ever actually in the document's layout flow at a time — the
 * inactive one is `display:none`, so it reserves zero height. This is why
 * switching panels can never leave a tall blank gap where the previous
 * panel's full content used to be, and why an inactive panel's real content
 * — however long — can never affect that panel's own box height: it simply
 * is not rendered while inactive. Only the short, purpose-built preview is.
 * The inactive wrapper also stays out of the tab order and off-screen for
 * assistive tech via aria-hidden (set in JS). */
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-full-content {
    display: none;
}
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel.is-active .suite-ip-full-content {
    display: block;
}
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-preview-content {
    display: block;
}
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel.is-active .suite-ip-preview-content {
    display: none;
}
/* A panel with no preview configured (preview_mode=off) only ever renders
 * .suite-ip-full-content — when inactive it simply shows nothing below the
 * title. */

/* Inactive panel title treatments. */
.suite-ip-root.ip-js.ip-mode-expand[data-ip-title-mode="centered"] .suite-ip-panel:not(.is-active) .suite-ip-panel__header {
    justify-content: center;
    text-align: center;
}
.suite-ip-root.ip-js.ip-mode-expand[data-ip-title-mode="vertical"] .suite-ip-panel:not(.is-active) .suite-ip-panel__header {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    justify-content: center;
    align-items: center;
    height: 100%;
}
.suite-ip-root.ip-js.ip-mode-expand[data-ip-title-mode="vertical"] .suite-ip-panel:not(.is-active) .suite-ip-panel__icon {
    transform: rotate(180deg);
}
/* Consistent desktop header height regardless of whether a title ends up on
 * one line or wraps onto its allowed second line (horizontal title mode
 * only — centered/vertical modes keep their own treatment above), so the
 * row of panel headers never looks uneven. Height reserved via
 * --ip-header-min-height, computed in FrontEnd.php from the configured
 * title font-size/line-height for exactly two lines. */
.suite-ip-root.ip-js.ip-mode-expand[data-ip-title-mode="horizontal"] .suite-ip-panel__header {
    min-height: var(--ip-header-min-height, auto);
}
/* Up to two lines, whole words only (never ellipsis after a single line, and
 * never letter-split a word) — applies to active and inactive titles alike
 * so every header stays aligned. Content past the second line is clipped. */
.suite-ip-root.ip-js.ip-mode-expand[data-ip-title-mode="horizontal"] .suite-ip-panel__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    width: 100%;
}

/* Desktop: the whole inactive (preview) column is a click target (see the
 * click handler in frontend.js; the header button stays the only focusable
 * control). Hover, or keyboard focus on that header, darkens the header with
 * a translucent overlay over whatever colour it already has. */
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel:not(.is-active) { cursor: pointer; }
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel__header { position: relative; }
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel:not(.is-active) .suite-ip-panel__header::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, .05);
    opacity: 0;
    pointer-events: none;
}
@media (hover: hover) {
    .suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel:not(.is-active):hover .suite-ip-panel__header::after { opacity: 1; }
}
.suite-ip-root.ip-js.ip-mode-expand .suite-ip-panel:not(.is-active) .suite-ip-panel__header:focus-visible::after { opacity: 1; }

/* ── JS-enhanced tab mode (mobile/tablet) — a conventional tab component.
 * Only the active panel's entire body is shown at full component width;
 * there is no preview concept and no reserved desktop shared-height in this
 * mode (recalcLayout() clears --ip-content-height outside ip-mode-expand),
 * so the content area naturally sizes to whichever tab is open. ── */
.suite-ip-root.ip-js.ip-mode-tabs .suite-ip-panel__header { display: none; }
.suite-ip-root.ip-js.ip-mode-tabs .suite-ip-panels { flex-direction: column; }
.suite-ip-root.ip-js.ip-mode-tabs .suite-ip-panel { flex: 1 1 auto; width: 100%; max-width: 100%; }
.suite-ip-root.ip-js.ip-mode-tabs .suite-ip-panel__body { display: none; width: 100%; max-width: 100%; }
/* Only ever set when Desktop Interaction Mode is Classic Tabs AND its own
 * "Tallest tab height" option is selected (see frontend.js::recalcLayout) —
 * --ip-content-height is never set in plain mobile tabs, so the `auto`
 * fallback keeps mobile's existing natural per-tab sizing completely
 * unchanged by default. */
.suite-ip-root.ip-js.ip-mode-tabs .suite-ip-panel.is-active .suite-ip-panel__body { display: block; min-height: var(--ip-content-height, auto); }
.suite-ip-root.ip-js.ip-mode-tabs .suite-ip-full-content { opacity: 1; visibility: visible; }
.suite-ip-root.ip-js.ip-mode-tabs .suite-ip-preview-content { display: none; }
/* Subtle content fade on tab switch — never the desktop sliding-panel motion. */
.suite-ip-root.ip-js.ip-mode-tabs:not(.ip-no-animate) .suite-ip-panel.is-active .suite-ip-panel__body {
    animation: suite-ip-tab-fade-in var(--ip-duration, 380ms) var(--ip-easing, ease);
}
@keyframes suite-ip-tab-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Reduced motion — always disable the sliding/opacity transitions. */
@media (prefers-reduced-motion: reduce) {
    .suite-ip-root.ip-js .suite-ip-panel,
    .suite-ip-root.ip-js .suite-ip-panel__body,
    .suite-ip-root.ip-js .suite-ip-full-content,
    .suite-ip-root.ip-js .suite-ip-preview-content {
        transition: none !important;
        animation: none !important;
    }
}
