/*
  Everything this application adds to Industry, kept OUT of industry.css.

  industry.css is byte-identical to the handoff bundle so a design update can be dropped straight
  in. Anything edited into it would be silently lost the first time that happens - so the dark
  scope and app-level rules live here instead, and this file is the one to read when the app looks
  different from the prototype.
*/

/*
  Dark theme.

  Industry ships no dark tokens. Per the handoff this RE-POINTS the existing variables rather than
  inventing a second palette, so every component keeps working without a dark-specific rule. Taken
  from the handoff as written.
*/
/*
    WHAT THE BROWSER PAINTS, as opposed to what we paint.

    A select's drop-down list, a date picker, a scrollbar and a focus ring are drawn by the browser,
    not by this stylesheet, and it picks their colours from color-scheme alone - which this
    application never declared. So every native control stayed in the light scheme while the page
    around it went dark: the share dialog's "Open for" list rendered as grey-on-grey, legible only
    for the row under the cursor.

    Declared against the same .dark class the palette uses, rather than a prefers-color-scheme
    query, because the theme here is a CHOICE first - App.razor sets that class from localStorage
    before any stylesheet paints, and falls back to the media query only when nobody has chosen. A
    media query here would disagree with the toggle the moment somebody used it.
*/
:root {
  color-scheme: light;
}

/*
    AND THE DROP-DOWN LIST ITSELF, which color-scheme does not reach.

    color-scheme fixes the chrome a browser draws around a control - the scrollbars, the focus ring,
    the select's own arrow - and it is necessary. It is not sufficient: once an author sets a
    background on a <select>, Chrome stops painting the popup from the scheme and paints each row
    from the option's own background, which defaults to white. The result is a dark page with a
    bright list hanging off it, and the first fix did not touch it.

    Here rather than in a component, because all three selects in this application have it - the
    plan picker on the administration page and the label-language picker in the viewer have been
    doing this for as long as there has been a dark theme.
*/
select option,
select optgroup {
  background: var(--color-surface);
  color: var(--color-text);
}

.dark {
  color-scheme: dark;

  --color-bg: #191c1f;
  --color-surface: #23272b;
  --color-text: #e9ebec;
  --color-accent: #94bce3;        /* lifted for contrast on dark */
  --color-divider: color-mix(in srgb, #e9ebec 20%, transparent);
  --shadow-sm: 0 1px 2px color-mix(in srgb, #000 40%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #000 45%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #000 55%, transparent);
}

.dark .tag-accent  { background: var(--color-accent-800); color: var(--color-accent-200); }
.dark .tag-neutral { background: var(--color-neutral-800); color: var(--color-neutral-200); }

/*
  The page itself. The prototype draws each screen as a fixed-width .screen box on a canvas; a real
  page is the document, so the ground and type come from the tokens here instead.
*/
html, body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}

/*
  Fluid where the prototype is fixed.

  The handoff is explicit: the drawn widths are the DESKTOP case, and landing/plans/account reflow
  below it. The prototype's 1440px is a canvas artefact, not a layout instruction - so the page
  centres on a max-width and the grids collapse.
*/
.page {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
}

/* Horizontal rhythm. One value, so the nav, every section and the footer line up down the page. */
.page-pad { padding-inline: 24px; }

@media (max-width: 860px) {
  .page-pad { padding-inline: 12px; }
}

/*
  Full-bleed bands (the plan strip) still need their CONTENT aligned to the page column, so the
  colour runs edge to edge while the type stays on the grid.
*/
.bleed { width: 100%; }
.bleed > .page { max-width: 1440px; }

/*
  Landing reflow.

  The handoff: "Treat the drawn width as the desktop case and let content reflow below it - grid
  tracks that collapse from three to two to one." These are the collapses for screen 1a. The 560px
  hero card and the 320px heading column are the two tracks that cannot simply shrink.
*/

@media (max-width: 1100px) {
  .landing-hero      { grid-template-columns: minmax(0, 1fr) !important; gap: 40px !important; }
  .landing-cards     { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .landing-audiences { grid-template-columns: minmax(0, 1fr) !important; gap: 28px !important; }
  .landing-planstrip { grid-template-columns: minmax(0, 1fr) !important; gap: 28px !important; }
  .landing-footer    { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 720px) {
  .landing-cards        { grid-template-columns: minmax(0, 1fr) !important; }
  .landing-audience-grid{ grid-template-columns: minmax(0, 1fr) !important; }
  .landing-footer       { grid-template-columns: minmax(0, 1fr) !important; }

  /* The 60px hero headline is a desktop size; at phone width it overflows its own line box. */
  .landing-hero h1      { font-size: 40px !important; }

  /* Wide buttons stack rather than squeeze below their 26px inline padding. */
  .landing-hero-actions { flex-wrap: wrap; }

  /* The reassurance row reads as a list once it wraps; the separators stop helping. */
  .landing-reassure     { flex-wrap: wrap; gap: 6px 14px !important; }

  .landing-nav-links    { display: none !important; }
}

/*
  A BUTTON IN THE NAV KEEPS ITS OWN COLOUR.

  industry.css:245 says `.nav a { color: inherit }`, which is right for a nav LINK and wrong for a
  nav BUTTON: at (0,1,1) it outranks `.btn-primary { color: var(--color-bg) }` at (0,1,0), so the
  primary call to action silently takes the nav's text colour instead of its own.

  In the light prototype that only looks slightly off - dark ink on steel-blue, about 4:1. Under the
  dark scope it becomes #e9ebec on #94bce3, roughly 1.3:1, and "Start free" is unreadable. The bug
  is in the design system, not in this page; it is repaired here because industry.css is kept
  byte-identical to the handoff so design updates can be dropped in. Worth reporting upstream.
*/
.nav a.btn-primary { color: var(--color-bg); }
.nav a.btn-ghost   { color: var(--color-accent); }

/* Screen-reader-only labels on icon buttons: the icon carries the meaning visually, the text
   carries it to anyone who cannot see the icon. */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The segmented controls are now real <button>s, not the prototype's radio labels, so they need
   the button reset that .seg-opt's label styling assumed. */
.seg button.seg-opt {
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* The active option in a server-rendered or script-driven segmented control. The prototype uses
   :checked on a hidden radio; with buttons the state lives in aria-pressed, which is also what a
   screen reader announces - one source rather than a class kept in step by hand. */
.seg button.seg-opt[aria-pressed="true"] {
  background: var(--color-accent);
  color: var(--color-bg);
}

/* ── Application pages ──────────────────────────────────────────────────────────────────────────
   The workspace and the viewer behave like an application, not a document: the window is the frame,
   nothing scrolls the page itself, and whatever needs to scroll does so inside its own pane.

   The informational pages - the front page, plans, standards - stay ordinary scrolling documents.
   They are read top to bottom and a fixed shell would fight that.

   position:fixed rather than height:100vh, because 100vh on mobile browsers is the height the
   viewport would have without the URL bar, which is not the height it has. */
.app-shell {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
}

/* Every pane inside a flex column needs min-height:0 or it refuses to shrink below its content,
   which is how a "fixed" layout ends up scrolling the page anyway.

   flex:none IN THE SAME BREATH, because min-height:0 on its own makes the CHROME shrinkable too.
   A flex column short of room takes it from every item in proportion to that item's base size, so
   a tall inspector panel was quietly paying for itself out of the navigation bar: measured at
   1920x1080, the bar stood at 53px with the Fact tab open, 44.9px once a fact was selected, and
   27.3px on Contents, whose 3193px of headings squeezed it to half its height. The pane that fills
   the shell takes the whole deficit; the rules below re-grant it flex:1 1 auto. */
.app-shell > * {
    flex: none;
    min-height: 0;
}

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

/* The pane that fills the rest and scrolls on its own. */
.app-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

/* The rail and whatever it lists, side by side, filling what the shell has left. */
.app-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.app-body > *:last-child {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

@media (max-width: 860px) {
    .app-body {
        display: block;
        overflow: auto;
    }
}

/* ── The shared components' palette ─────────────────────────────────────────────────────────────
   WbUploadPresentationView, WbRenderPlanView and WbTableModelGrid come from the Workbench and are
   built on its design tokens. Their stylesheet ships with them; their COLOURS are mapped here, to
   the Industry tokens, so the panes look like XBRL Studio rather than like the Workbench.

   Mapped rather than class-switched. tokens.css applies its palette through .tx-light / .tx-dark,
   which a component cannot choose from CSS - and a JavaScript round trip to read the theme would
   not follow a reader toggling it. Industry's own tokens already flip in dark mode, so aliasing to
   them means these panes follow along with no code at all.

   No literal fallbacks: a fallback wins when the real token is missing and the mistake then shows
   up only in one theme.

   ON THE ROOT, not only on the filing panes (2026-11-04). Shared components now live outside them
   too - the reconnect dialog, the package hash dialog - and outside a mapped pane every --tx-*
   colour was undefined: the reconnect dialog's surface resolved to transparent. .dark sits on the
   same element (<html>), so these resolve to the current theme's colours and still follow the
   toggle. */
:root {
    --tx-font-sans: var(--font-body);
    --tx-font-mono: var(--font-mono, ui-monospace, monospace);

    /* The Industry system's corners: square, softened by two pixels. Undefined, a shared
       component's radius resolved to nothing and was square only by accident. */
    --tx-radius-sm: 2px;
    --tx-radius: 2px;

    --tx-text-primary: var(--color-text);
    --tx-text-secondary: color-mix(in srgb, var(--color-text) 62%, transparent);
    --tx-text-disabled: color-mix(in srgb, var(--color-text) 38%, transparent);

    --tx-bg-default: var(--color-bg);
    --tx-bg-paper: var(--color-surface);
    --tx-bg-elevated: var(--color-surface);
    --tx-menu-bg: var(--color-surface);
    --tx-card-bg: var(--color-surface);
    --tx-card-outlined-bg: transparent;

    --tx-divider: var(--color-divider);
    --tx-action-hover: color-mix(in srgb, var(--color-text) 6%, transparent);
    --tx-action-selected: color-mix(in srgb, var(--color-accent) 12%, transparent);

    --tx-primary-main: var(--color-accent);
    --tx-primary-light: var(--color-accent-400);
    --tx-primary-dark: var(--color-accent-700);
    --tx-primary-contrast: var(--color-bg);

    --tx-secondary-main: var(--color-accent-2);
    --tx-secondary-accent: var(--color-accent-2);

    --tx-info-main: var(--color-accent);
    --tx-info-light: var(--color-accent-200);
    --tx-info-dark: var(--color-accent-700);

    --tx-success-main: var(--color-accent);
    --tx-success-light: var(--color-accent-200);
    --tx-success-dark: var(--color-accent-700);

    --tx-warning-main: var(--color-accent-2);
    --tx-warning-light: var(--color-accent-2-200);
    --tx-warning-dark: var(--color-accent-2-700);

    --tx-error-main: var(--color-accent-2);
    --tx-error-light: var(--color-accent-2-200);
    --tx-error-dark: var(--color-accent-2-700);

    --tx-focus-ring: var(--color-accent);
    --tx-shadow-base: 0 1px 2px rgb(0 0 0 / 12%);
}

/* ── The modal frame, shared ─────────────────────────────────────────────────────────────────────
 *
 * GLOBAL RATHER THAN SCOPED, and that is the whole reason these moved. Scoped CSS compiles to
 * .class[b-abc123], so a second dialog reusing the first one's class names gets none of its
 * styling - the markup looks right and renders unstyled. The choice is therefore between copying
 * the frame into every dialog and naming it once here; the wb-view- consolidation in the shared
 * viewer library settled that question for the same reason.
 *
 * What stays scoped is what a given dialog is ABOUT - the hash figure, the share fields. This is
 * only the box they sit in.
 */

.dialog-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgb(0 0 0 / 38%);
}

.dialog-frame {
    position: fixed;
    z-index: 61;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 760px;
    max-width: calc(100vw - 32px);
    max-height: min(80vh, 760px);
    display: flex;
    flex-direction: column;
    padding: 22px 24px 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: 10px;
    box-shadow: 0 24px 64px rgb(0 0 0 / 34%);
}

.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex: none;
}

.dialog-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 19px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

/* The one part that scrolls, so a dialog's heading stays put while its body is read. */
.dialog-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 18px;
}
