/*
 * app-shell.css — domain CSS classes for the shared application shell
 * partials: layout wrapper, navigation, toast notifications, flash
 * messages, audit history, and upload previews.
 *
 * ============================================================
 *  DESIGN SYSTEM RULES — read before adding any CSS to this file
 * ============================================================
 *
 *  1. VALUES
 *     Never hardcode colors or spacing. Always use var(--color-*) and
 *     calc(var(--spacing) * N). No #hex, no rgb(), no raw px/rem for
 *     color or spacing. Raw rem is OK for non-spacing, non-color
 *     dimensions (max-width, border-radius, font-size, breakpoints)
 *     when no token fits — but prefer tokens where they exist.
 *
 *  2. REACH FOR PRIMITIVES FIRST (see primitives.css)
 *       Layout?      Use .stack, .stack-sm, .stack-lg, .row, .row-between,
 *                    .cluster, .switcher, .center, .grid-auto, .box.
 *       Typography?  Use .text-heading, .text-body, .text-muted.
 *       Surface/bg?  Use .surface, .surface-elevated, .border-subtle.
 *     If the markup can be expressed as primitives, STOP. Do not create
 *     a new class. Duplication is worse than an imperfect class name.
 *
 *  3. NEW CLASSES ONLY WHEN ALL THREE HOLD
 *     a. The combination appears 3+ times (rule of three).
 *     b. You can name it after the domain thing (".app-shell-toast"),
 *        not appearance (".gray-card-with-border").
 *     c. It is NOT expressible as a one-line primitive combo.
 *
 *  4. NAMING
 *     All classes in this file are prefixed .app-shell-*.
 *     Cross-area primitives live in primitives.css and stay unprefixed.
 *     Do NOT add new primitives from inside this file — discuss first.
 *
 *  5. DOCUMENT
 *     Every class gets a doc-comment block directly above it stating:
 *       - What the class represents
 *       - Where it's used (file paths)
 *       - When to reuse it
 *       - When NOT to use it (and what to use instead)
 *     This is the agent-legibility feature. Without it, agents can't
 *     tell when to reuse vs when to create.
 *
 *  6. NO NESTING beyond one level. No @apply. No utility-class soup.
 *     If you find yourself writing `.foo .bar .baz { ... }`, stop and
 *     rethink. Flat CSS only.
 *
 *  7. WHEN IN DOUBT, REUSE.
 *     An imperfect class name you can rename later is better than
 *     two classes that drift apart.
 */


/* ============================================================
 *  SHELL LAYOUT — _application_shell.html.erb
 * ============================================================ */

/*
 * .app-shell
 * Root layout wrapper for the authenticated application shell.
 * Sets minimum viewport height so the sidebar and content fill
 * the screen.
 *
 * Where used: app/views/application/_application_shell.html.erb (root div)
 * Reuse: only on the outermost shell wrapper
 * Do NOT use for: inner page containers — use .center or .box instead
 */
.app-shell {
  min-height: 100vh;
}

/*
 * .app-shell-skip-link
 * "Skip to main content" link — the first focusable element on the page,
 * rendered as the first child of <body> in application.html.erb, ahead of
 * both the sidebar and the impersonation tab. Hidden via the sr-only clip
 * technique at rest so it never affects layout; on keyboard focus it
 * un-clips into a floating pill above the sidebar so keyboard and
 * screen-reader users can jump straight past nav chrome to #main-content.
 *
 * Where used: app/views/layouts/application.html.erb
 * Reuse: never — this is the one skip link for the page shell
 * Do NOT use for: other visually-hidden text — use .sr-only for that
 */
.app-shell-skip-link {
  position: absolute;
  top: 0;
  left: 0;
  width: 0.0625rem;
  height: 0.0625rem;
  padding: 0;
  margin: -0.0625rem;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.app-shell-skip-link:focus-visible {
  z-index: 60;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  top: calc(var(--spacing) * 4);
  left: calc(var(--spacing) * 4);
  padding: calc(var(--spacing) * 2) calc(var(--spacing) * 4);
  background: var(--color-surface-primary);
  color: var(--color-text-heading);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg), var(--focus-ring);
  font-size: var(--font-size-sm);
  font-weight: 500;
  outline: none;
}

/*
 * .app-shell-main-area
 * Main content column beside the sidebar.
 *
 * Where used: app/views/application/_application_shell.html.erb
 * Reuse: only on the main content wrapper inside .app-shell
 * Do NOT use for: page-level content wrappers — use .app-shell-content-padded
 */
.app-shell-main-area {
  position: relative;
  min-height: 100vh;
}

/*
 * .app-shell-main-area-with-sidebar
 * Modifier applied alongside .app-shell-main-area when the sidebar is
 * visible. On large screens it offsets the fixed 14rem (60 spacing units)
 * sidebar; on mobile the sticky top bar occupies flow space at the top of
 * the column, so no offset is needed (see the mobile block below).
 *
 * Tying this to the sidebar's presence keeps full-screen / hide-sidebar
 * pages (e.g. the audience builder) flush — there's no mobile top bar.
 *
 * Where used: app/views/application/_application_shell.html.erb (conditional)
 * Reuse: only when the sidebar is rendered
 * Do NOT use for: any other left-offset layout
 */
@media (max-width: 63.9375rem) {
  /*
   * Mobile shell becomes a vertical flex column so the sticky top bar
   * (.component-sidebar-mobile-topbar) occupies real flow space at the top
   * and the content area fills the rest. display: contents dissolves the
   * SidebarComponent wrapper box so the bar participates as a flex child of
   * .app-shell — giving position: sticky the full page height to travel,
   * which keeps the bar pinned without the drift that position: fixed shows
   * on iOS while the URL bar collapses.
   */
  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }

  .component-sidebar {
    display: contents;
  }

  .app-shell-main-area {
    flex: 1 1 auto;   /* fill the column so full-screen content (height: 100%) resolves */
    min-height: 0;    /* override base min-height: 100vh so flex distributes height */
  }

}

@media (min-width: 64rem) {
  .app-shell-main-area-with-sidebar {
    padding-left: calc(var(--spacing) * 60);
  }
}

/*
 * .app-shell-impersonating
 * Set on .app-shell while a super admin impersonates someone. On desktop the
 * impersonation tab is fixed over the top of the content, so this holds the
 * room it takes as a custom property: the content, the toast overlay and every
 * page-level sticky header start below the tab instead of sliding under it.
 * Below 64rem the tab sits in the flow under the mobile top bar and needs no
 * room held for it.
 *
 * Where used: app/views/application/_application_shell.html.erb (conditional)
 * Reuse: only on .app-shell
 * Do NOT use for: anything outside the signed-in shell
 */
@media (min-width: 64rem) {
  /* The tab's own height, summed from its parts so the reserve tracks them:
     its block padding (1.5 + 1.5), its bottom edge (1), and the small button
     it holds (2 + 2 padding, a 1rem line, a 1px hairline top and bottom). */
  .app-shell-impersonating {
    --app-shell-impersonation-offset: calc(var(--spacing) * (1.5 + 1.5 + 1 + 2 + 2) + 1rem + 0.125rem);
  }

  .app-shell-impersonating .app-shell-content {
    padding-top: var(--app-shell-impersonation-offset);
  }

  .app-shell-impersonating ~ .app-shell-toast-overlay {
    padding-top: calc(var(--spacing) * 16);
  }
}

/*
 * .app-shell-impersonation-frame
 * A 4px ring around the whole viewport while a super admin impersonates
 * someone: in peripheral vision on every page, the sidebar-less builder and
 * onboarding included. Purple mark in light, orange mark in dark: the orange
 * mark reads brown on Cool Paper, and the bright orange base is banned as a
 * light-mode accent. A border rather than a labelled fill, so the solid mark
 * color is allowed. Never takes a click.
 *
 * Where used: app/components/impersonation_frame_component.html.erb
 * Reuse: only for the impersonation frame
 * Do NOT use for: other alerts or outlines — use .app-shell-flash or a box
 */
.app-shell-impersonation-frame {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  box-shadow: inset 0 0 0 calc(var(--spacing) * 1) var(--color-purple-mark);
}

[data-theme="dark"] .app-shell-impersonation-frame {
  box-shadow: inset 0 0 0 calc(var(--spacing) * 1) var(--color-orange-mark);
}

/*
 * .app-shell-impersonation-tab
 * The tab hanging from the frame's top edge: who is being impersonated, the
 * account every change lands in, and Switch / Back to me, under the frame's
 * mark-colored edge. Light takes the purple tonal recipe (status ink on an 18%
 * tint, 8.48:1) with purple buttons; dark sits on the plain card surface with
 * heading ink (17.9:1), an orange icon and edge, and gray buttons, because an
 * orange tint on the dark page reads brown. Sits above the sticky mobile top
 * bar (40) and below toasts (50), the sidebar popover and drawers (60) and
 * modals.
 *
 * On desktop it is fixed and its text stays on one line. Below 64rem it pins
 * under the mobile top bar in the flow and wraps: the account and the person
 * beside the actions, the consequence on its own line beneath, neither
 * truncated, so the content below starts wherever the tab ends.
 *
 * Where used: app/components/impersonation_frame_component.html.erb
 * Reuse: only for the impersonation tab
 * Do NOT use for: other banners — use .app-shell-flash instead
 */
.app-shell-impersonation-tab {
  position: fixed;
  top: 0;
  left: calc(var(--spacing) * 60 + var(--spacing-page-x));
  z-index: 46;
  display: flex;
  align-items: center;
  gap: calc(var(--spacing) * 3);
  max-width: calc(100% - var(--spacing) * 60 - var(--spacing-page-x) * 2);
  padding: calc(var(--spacing) * 1.5) calc(var(--spacing) * 2) calc(var(--spacing) * 1.5) calc(var(--spacing) * 4);
  background: color-mix(in srgb, var(--color-purple) 18%, var(--color-surface-body));
  border: calc(var(--spacing) * 1) solid var(--color-purple-mark);
  border-top: 0;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  color: var(--color-status-text-purple);
  font-size: var(--font-size-sm);
}

[data-theme="dark"] .app-shell-impersonation-tab {
  background: var(--color-surface-primary);
  border-color: var(--color-orange-mark);
  color: var(--color-text-heading);
}

[data-theme="dark"] .app-shell-impersonation-tab-icon {
  color: var(--color-orange-mark);
}

/* The tab renders its buttons purple; in dark they take the gray variant's
   recipe instead, so the only color on the tab is the orange edge and icon. */
[data-theme="dark"] .app-shell-impersonation-tab .component-button-purple {
  background: var(--color-surface-primary);
  border-color: var(--color-border-themed);
  color: var(--color-text-heading);
}

[data-theme="dark"] .app-shell-impersonation-tab .component-button-purple:hover,
[data-theme="dark"] .app-shell-impersonation-tab .component-button-purple:active {
  background: var(--color-surface-elevated);
  border-color: var(--color-border-strong);
}

.app-shell-impersonation-tab-without-sidebar {
  left: var(--spacing-page-x);
  max-width: calc(100% - var(--spacing-page-x) * 2);
}

.app-shell-impersonation-tab-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.app-shell-impersonation-tab-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell-impersonation-tab-text strong {
  font-weight: 600;
}

.app-shell-impersonation-tab-actions {
  display: flex;
  gap: calc(var(--spacing) * 2);
  flex-shrink: 0;
}

.app-shell-impersonation-tab-short,
.app-shell-impersonation-tab-consequence {
  display: none;
}

@media (max-width: 63.9375rem) {
  .app-shell-impersonation-tab {
    position: sticky;
    top: 3.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    row-gap: 0;
    max-width: none;
    margin-inline: var(--spacing-page-x);
  }

  .app-shell-impersonation-tab-without-sidebar {
    top: 0;
  }

  .app-shell-impersonation-tab-long {
    display: none;
  }

  .app-shell-impersonation-tab-short {
    display: inline;
  }

  .app-shell-impersonation-tab-text {
    white-space: normal;
  }

  .app-shell-impersonation-tab-consequence {
    display: block;
    grid-column: 2 / -1;
  }
}

/*
 * .app-shell-content
 * The <main> element inside the shell. Flex child that grows to
 * fill remaining vertical space.
 *
 * Where used: app/views/application/_application_shell.html.erb
 * Reuse: only on the <main> element
 * Do NOT use for: content sections within pages
 */
.app-shell-content {
  flex: 1;
  position: relative;
  min-width: 0;
}

.app-shell-content:focus {
  outline: none;
}

/*
 * .app-shell-content-padded
 * Standard horizontal and bottom padding for non-full-screen page
 * content. Applied inside <main> when content_for?(:full_screen_layout)
 * is false.
 *
 * The bottom gutter is --spacing-page-bottom rather than the page rhythm
 * because it also has to clear the support chat launcher pinned to the
 * bottom-right corner of the viewport; see the token's note in
 * primitives.css before shrinking it.
 *
 * Where used: app/views/application/_application_shell.html.erb
 * Reuse: only on the default content wrapper
 * Do NOT use for: full-screen layouts (they get no padding wrapper)
 */
.app-shell-content-padded {
  padding: 0 var(--spacing-page-x) var(--spacing-page-bottom);
}

/*
 * .app-shell-content-fill
 * Forces the <main> element and its full-screen content wrapper to
 * fill the available height. Applied inside _application_shell.html.erb
 * when content_for?(:full_screen_layout) is true.
 *
 * Where used: app/views/application/_application_shell.html.erb
 * Reuse: only on the full-screen-layout main and its inner wrapper
 * Do NOT use for: regular page content — the default flow handles it
 */
.app-shell-content-fill {
  height: 100%;
}

/*
 * .app-shell-full-screen-fill
 * Page-level wrapper for views rendered under full_screen_layout that
 * need the page content to extend to the bottom of the viewport.
 *
 * Where used: app/views/my_tasks/active.html.erb,
 *             app/views/my_tasks/completed.html.erb,
 *             app/views/team_capacities/show.html.erb
 * Reuse: outermost wrapper of any full_screen_layout view that should
 *        fill remaining vertical space
 * Do NOT use for: regular pages — they already inherit page padding
 */
.app-shell-full-screen-fill {
  min-height: 100%;
}


/* ============================================================
 *  NAVIGATION — _navigation.html.erb
 * ============================================================ */

/*
 * .app-shell-navigation
 * Outer wrapper for the page header. Owns only the horizontal page gutter;
 * the PageHeaderComponent inside owns the vertical rhythm (default or hero).
 *
 * Where used: app/views/application/_navigation.html.erb
 * Reuse: only for the page-level navigation wrapper
 * Do NOT use for: section headers within a page
 */
.app-shell-navigation {
  padding-inline: var(--spacing-page-x);
}


/* ============================================================
 *  TOAST NOTIFICATIONS — _notifications.html.erb, _notification.html.erb
 * ============================================================ */

/*
 * .app-shell-toast-overlay
 * Fixed full-screen overlay for toast notifications. Pointer events
 * are disabled so clicks pass through to the page. Toasts appear
 * at the bottom on mobile, top on large screens.
 *
 * Where used: app/views/application/_notifications.html.erb
 * Reuse: only for the toast overlay container
 * Do NOT use for: modal overlays — modals have their own component
 */
.app-shell-toast-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: calc(var(--spacing) * 6);
  pointer-events: none;
  z-index: 50;
}

@media (min-width: 64rem) {
  .app-shell-toast-overlay {
    align-items: flex-start;
  }
}

/*
 * .app-shell-toast-stack
 * Vertical stack of toast notifications inside the overlay.
 * Centered horizontally, spaced with a gap.
 *
 * Where used: app/views/application/_notifications.html.erb
 * Reuse: only inside .app-shell-toast-overlay
 * Do NOT use for: other vertical stacks — use .stack
 */
.app-shell-toast-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--spacing) * 4);
}

/*
 * .app-shell-toast
 * Individual toast notification card. Re-enables pointer events
 * so the dismiss button is clickable. Rounded, elevated surface
 * with a border.
 *
 * Where used: app/views/application/_notification.html.erb
 * Reuse: only for toast notifications
 * Do NOT use for: inline alerts — use .app-shell-flash
 */
.app-shell-toast {
  max-width: 24rem;
  width: 100%;
  background: var(--color-surface-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  overflow: hidden;
  border: 1px solid var(--color-border-themed);
}

.app-shell-toast:focus {
  outline: none;
}

/*
 * .app-shell-toast-in-place
 * The confirmation of an edit saved in a table cell. Below the large
 * breakpoint the stack sits at the bottom of the screen, over the rows being
 * typed in, and the redrawn cell already shows the save, so the toast is
 * visually hidden there and still announced by the stack's live region.
 *
 * Where used: app/views/application/_notification.html.erb (in_place: true)
 * Reuse: only for a save the cell it was made in already shows
 * Do NOT use for: refusals or saves made away from the page — those need the
 *   visible toast
 */
@media (max-width: 63.99rem) {
  .app-shell-toast-in-place {
    position: absolute;
    width: 0.0625rem;
    height: 0.0625rem;
    padding: 0;
    margin: -0.0625rem;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/*
 * .app-shell-toast-positive
 * Modifier for success/notice toasts. Colors the status icon green
 * via a descendant selector on the icon wrapper.
 *
 * Where used: app/views/application/_notification.html.erb (color == :green)
 * Reuse: on any .app-shell-toast that represents a success/notice
 * Do NOT use for: flash messages — use .app-shell-flash-positive
 */
.app-shell-toast-positive .app-shell-toast-icon {
  color: var(--color-text-success);
}

/*
 * .app-shell-toast-negative
 * Modifier for error/alert toasts. Colors the status icon red.
 *
 * Where used: app/views/application/_notification.html.erb (color == :red)
 * Reuse: on any .app-shell-toast that represents an error/alert
 * Do NOT use for: flash messages — use .app-shell-flash-negative
 */
.app-shell-toast-negative .app-shell-toast-icon {
  color: var(--color-text-danger);
}

/*
 * .app-shell-toast-body
 * Inner flex row of the toast containing icon, message, and
 * dismiss button.
 *
 * Where used: app/views/application/_notification.html.erb
 * Reuse: only inside .app-shell-toast
 * Do NOT use for: other flex rows — use .row
 */
.app-shell-toast-body {
  display: flex;
  align-items: center;
  padding: calc(var(--spacing) * 4);
}

/*
 * .app-shell-toast-message
 * Message text area inside a toast. Uses the w-0 + flex-1 pattern
 * to allow the text to truncate rather than push the dismiss button
 * off-screen.
 *
 * Where used: app/views/application/_notification.html.erb
 * Reuse: only inside .app-shell-toast-body
 * Do NOT use for: standalone text — use .text-heading or .text-body
 */
.app-shell-toast-message {
  margin-left: calc(var(--spacing) * 4);
  width: 0;
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--color-text-heading);
}

/*
 * .app-shell-toast-dismiss
 * Dismiss button for toast notifications. Muted icon color that
 * becomes heading color on hover.
 *
 * Where used: app/views/application/_notification.html.erb
 * Reuse: only inside .app-shell-toast-body
 * Do NOT use for: other dismiss/close buttons — components have their own
 */
.app-shell-toast-dismiss {
  margin-left: calc(var(--spacing) * 4);
  flex-shrink: 0;
  display: inline-flex;
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.app-shell-toast-dismiss:hover {
  color: var(--color-text-heading);
}

/* Focus doctrine: keyboard focus shows the shared ring, never nothing. */
.app-shell-toast-dismiss:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}


/* ============================================================
 *  FLASH MESSAGES — _flash_message.html.erb
 * ============================================================ */

/*
 * .app-shell-flash
 * Inline flash message bar displayed at the top of page content.
 * Base styles: padding, rounded corners, bottom margin, hairline border.
 * Must be paired with a variant class (.app-shell-flash-positive or
 * .app-shell-flash-negative), which supplies the tint, border and ink.
 *
 * Where used: app/views/application/_flash_message.html.erb
 * Reuse: only for flash messages
 * Do NOT use for: toast notifications — use .app-shell-toast
 */
.app-shell-flash {
  padding: calc(var(--spacing) * 4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  margin-bottom: calc(var(--spacing) * 8);
}

/*
 * .app-shell-flash-positive / .app-shell-flash-negative
 * The two variants, both built on the design system's tinted-callout recipe:
 * an 18% tint of the status hue, a 35% tint as the hairline, and the hue's
 * own ink. Solid status fills are banned by the design system and the old
 * solid red measured 3.29:1 against its white text.
 *
 * The ink is the shared status ink (--color-status-text-*), which darkens in
 * light mode and lightens in dark. The base `-dark` tokens cannot clear WCAG
 * AA on a light tint at any strength (--color-red-dark tops out at 4.42:1 on
 * pure white). Measured with the shared ink, on both the card surface and
 * the page background:
 *   negative — 7.78:1 / 7.22:1 light, 6.92:1 / 7.64:1 dark
 *   positive — 6.42:1 / 6.00:1 light, 7.73:1 / 8.64:1 dark
 *
 * Where used: app/views/application/_flash_message.html.erb
 * Reuse: on any .app-shell-flash representing a success/notice or error/alert
 */
.app-shell-flash-positive {
  background: color-mix(in srgb, var(--color-green) 18%, transparent);
  border-color: color-mix(in srgb, var(--color-green) 35%, transparent);
  color: var(--color-status-text-green);
}

.app-shell-flash-negative {
  background: color-mix(in srgb, var(--color-red) 18%, transparent);
  border-color: color-mix(in srgb, var(--color-red) 35%, transparent);
  color: var(--color-status-text-red);
}

/*
 * .app-shell-flash-warning
 * The same tinted-callout recipe in yellow, for an advisory the user can act
 * on or dismiss without anything being wrong yet.
 *
 * Where used: app/views/application/_flash_message.html.erb (color: :yellow),
 *   e.g. Lists::ExcelRowLimitWarningComponent. Documented in DESIGN.md (Flash messages).
 * Reuse: on any .app-shell-flash carrying a non-blocking warning
 */
.app-shell-flash-warning {
  background: color-mix(in srgb, var(--color-yellow) 18%, transparent);
  border-color: color-mix(in srgb, var(--color-yellow) 35%, transparent);
  color: var(--color-status-text-yellow);
}

/*
 * .app-shell-flash-body
 * Flex row inside the flash bar: content on the left, dismiss
 * button on the right. Top-aligned, since a message that carries a recovery
 * action runs to two rows.
 *
 * Where used: app/views/application/_flash_message.html.erb
 * Reuse: only inside .app-shell-flash
 * Do NOT use for: other flex rows — use .row-between
 */
.app-shell-flash-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: calc(var(--spacing) * 2);
}

/*
 * .app-shell-flash-content
 * Icon + message grouping inside the flash bar.
 *
 * Where used: app/views/application/_flash_message.html.erb
 * Reuse: only inside .app-shell-flash-body
 * Do NOT use for: other icon+text combos — use .row
 */
.app-shell-flash-content {
  display: flex;
  align-items: flex-start;
  gap: calc(var(--spacing) * 4);
  min-width: 0;
}

/*
 * .app-shell-flash-message
 * Column holding the message text and, when a page supplies one, the
 * recovery action beneath it.
 *
 * Where used: app/views/application/_flash_message.html.erb
 * Reuse: only inside .app-shell-flash-content
 */
.app-shell-flash-message {
  min-width: 0;
}

/*
 * .app-shell-flash-text
 * The flash message text. Small and semibold; the line box matches the
 * icon's 1.25rem so the two align on the first line.
 *
 * Where used: app/views/application/_flash_message.html.erb
 * Reuse: only inside .app-shell-flash-message
 * Do NOT use for: standalone text
 */
.app-shell-flash-text {
  font-size: var(--font-size-sm);
  line-height: 1.25rem;
  font-weight: 600;
  overflow-wrap: break-word;
}

/*
 * .app-shell-flash-action
 * Wrapper for the recovery affordance a page attaches to its flash via
 * content_for(:flash_action) — "reset your password", "send it again".
 *
 * Where used: app/views/application/_flash_message.html.erb
 * Reuse: only inside .app-shell-flash-message
 */
.app-shell-flash-action {
  margin-top: calc(var(--spacing) * 2);
}

/*
 * .app-shell-flash-action-form
 * button_to wraps its button in a form; keep that form out of the layout so a
 * POST-backed recovery action sits inline like the link-backed ones.
 *
 * Where used: app/views/sessions/new.html.erb (resend confirmation),
 *   app/components/audiences/previous_version_notice_component.html.erb
 * Reuse: any button_to placed inside .app-shell-flash-action
 */
.app-shell-flash-action-form {
  display: inline;
}

/*
 * .app-shell-flash-link
 * The recovery affordance itself, as a link or as a button_to submit button.
 * Inherits the flash ink rather than taking the accent, so it reads as part
 * of the message and carries the variant's measured contrast.
 *
 * Where used: app/views/sessions/new.html.erb,
 *   app/components/audiences/previous_version_notice_component.html.erb,
 *   app/components/external_audiences/google_ad_reconnect_notice_component.html.erb
 * Reuse: only inside .app-shell-flash-action
 * Do NOT use for: standalone inline links — use .link-accent
 */
.app-shell-flash-link {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.125rem;
  cursor: pointer;
}

.app-shell-flash-link:hover {
  text-decoration-thickness: 0.125rem;
}

/* Focus doctrine: keyboard focus shows the shared ring, never nothing. */
.app-shell-flash-link:focus-visible {
  outline: none;
  border-radius: var(--radius-xs);
  box-shadow: var(--focus-ring);
}


/* ============================================================
 *  COMMENT FORM — comments/_form.html.erb
 * ============================================================ */

/*
 * .app-shell-comment-form
 * Outer wrapper for the inline comment/reply form shown below
 * comment threads. Top border separates it from the thread above,
 * flex row puts avatar beside the form body.
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only for the comment form wrapper
 * Do NOT use for: standalone forms — use form primitives
 */
.app-shell-comment-form {
  padding-top: calc(var(--spacing) * 4);
  padding-left: calc(var(--spacing) * 4);
  padding-right: calc(var(--spacing) * 4);
  border-top: 1px solid var(--color-border-themed);
  display: flex;
  gap: calc(var(--spacing) * 4);
}

/*
 * .app-shell-comment-avatar
 * User avatar beside the comment form. Hidden on mobile viewports,
 * shown as inline-flex on md+. Includes shrink-0 to prevent the
 * avatar from collapsing when the form grows.
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only inside .app-shell-comment-form
 */
.app-shell-comment-avatar {
  display: none;
  flex-shrink: 0;
  margin-top: calc(var(--spacing) * 1);
}

@media (min-width: 48rem) {
  .app-shell-comment-avatar {
    display: inline-flex;
  }
}

/*
 * .app-shell-comment-body
 * Flex-grow body of the comment form containing the rich text area,
 * error panel, and action buttons.
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only inside .app-shell-comment-form
 */
.app-shell-comment-body {
  flex: 1;
}

/*
 * .app-shell-comment-error
 * Error summary panel displayed when comment validation fails.
 * Red text on a light-red background.
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only inside .app-shell-comment-body
 * Do NOT use for: other error panels — use .vault-form-error-panel
 */
.app-shell-comment-error {
  background: color-mix(in srgb, var(--color-red) 18%, transparent);
  color: var(--color-text-danger);
  padding: calc(var(--spacing) * 2) calc(var(--spacing) * 4);
  font-weight: 500;
  border-radius: 0.5rem;
  margin-top: calc(var(--spacing) * 4);
  margin-bottom: calc(var(--spacing) * 4);
  font-size: var(--font-size-xs);
}

/*
 * .app-shell-comment-message-wrapper
 * Positioning context for the rich text area and the absolutely-
 * positioned .app-shell-comment-mention-dropdown that hangs off it.
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only around the comment textarea + mention dropdown pair
 * Do NOT use for: arbitrary positioning — use a domain-specific class
 */
.app-shell-comment-message-wrapper {
  position: relative;
}

/*
 * .app-shell-comment-list-frame
 * Container for the rendered comment list inside the
 * <%= turbo_frame_tag :comments %> stream. Adds a small bottom
 * margin so the comment form sits flush against the list without
 * overlapping the last comment's actions.
 *
 * Where used: app/views/comments/index.html.erb
 * Reuse: only on the comments turbo_frame body
 * Do NOT use for: arbitrary stack rhythm — prefer .stack / .stack-sm
 */
.app-shell-comment-list-frame {
  margin-bottom: calc(var(--spacing) * 1);
}

/*
 * .app-shell-comment-empty-state
 * Hides the initial empty guidance after Turbo appends the first comment.
 *
 * Where used: app/views/comments/index.html.erb
 * Reuse: only inside .app-shell-comment-list-frame
 */
.app-shell-comment-list-frame:has(.client-dashboard-comment) .app-shell-comment-empty-state {
  display: none;
}

/*
 * .app-shell-comment-mention-dropdown
 * Absolutely-positioned autocomplete dropdown for @-mentions in
 * the comment rich text area. Shows matching users. Anchored at the
 * typed "@" via --mention-dropdown-left/top custom properties set by
 * comment_mention_controller.js; falls back to below the editor.
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only for comment mention suggestions
 */
.app-shell-comment-mention-dropdown {
  position: absolute;
  z-index: 50;
  left: var(--mention-dropdown-left, 0);
  top: var(--mention-dropdown-top, 100%);
  width: 16rem;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--color-surface-primary);
  border: 1px solid var(--color-border-themed);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  margin-top: calc(var(--spacing) * 1);
}

/*
 * .app-shell-comment-no-results
 * "No users found" fallback text inside the mention dropdown.
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only inside .app-shell-comment-mention-dropdown
 */
.app-shell-comment-no-results {
  padding: calc(var(--spacing) * 2) calc(var(--spacing) * 4);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/*
 * .app-shell-comment-actions
 * Action row below the comment rich text area (toggle + submit button).
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only inside .app-shell-comment-body
 */
.app-shell-comment-actions {
  margin-top: calc(var(--spacing) * 4);
}

/*
 * .app-shell-comment-cancel
 * Cancel link beside the submit button when the comment form is reused for
 * inline editing. Dismisses the editor without saving.
 *
 * Where used: app/views/comments/_form.html.erb
 * Reuse: only inside .app-shell-comment-actions
 */
.app-shell-comment-cancel {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.app-shell-comment-cancel:hover {
  color: var(--color-text-heading);
}

/*
 * .app-shell-flash-dismiss
 * Dismiss button in flash messages. A real <button>, so it is tabbable and
 * carries an accessible name. The 2.75rem minimum meets WCAG 2.5.8's target
 * size around a 1.25rem icon; the negative margin lets that target overhang
 * into the flash's own padding, so the bar does not grow to 2.75rem of
 * content height for a one-line message.
 *
 * Where used: app/views/application/_flash_message.html.erb
 * Reuse: only inside .app-shell-flash-body
 */
.app-shell-flash-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin: calc(var(--spacing) * -2);
  padding: calc(var(--spacing) * 2);
  border: none;
  border-radius: var(--radius-lg);
  background: none;
  color: inherit;
  cursor: pointer;
}

.app-shell-flash-dismiss:hover {
  background: color-mix(in srgb, currentcolor 10%, transparent);
}

/* Focus doctrine: keyboard focus shows the shared ring, never nothing. */
.app-shell-flash-dismiss:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/*
 * .app-shell-dropzone-svg
 * Sizing for the upload cloud SVG in the default dropzone content.
 *
 * Where used: app/views/dropzone_input/_default_content.html.erb
 * Reuse: only for the default dropzone upload icon
 */
.app-shell-dropzone-svg {
  display: inline-block;
  width: 4rem;
  margin-bottom: calc(var(--spacing) * 1);
}

/*
 * .app-shell-dropzone-heading
 * Heading text inside the default dropzone content area.
 *
 * Where used: app/views/dropzone_input/_default_content.html.erb
 * Reuse: only for the default dropzone heading
 */
.app-shell-dropzone-heading {
  font-size: var(--font-size-lg);
  color: var(--color-text-body);
}


/* ═══ Framework integration ═══ */

/*
 * .translation_missing — Rails i18n highlights missing translation keys
 * with this class. Red background makes them unmissable during development.
 */
.translation_missing {
  background-color: color-mix(in srgb, var(--color-red) 25%, transparent);
  color: var(--color-text-danger);
}

/*
 * .turbo-progress-bar — Turbo's page-load progress indicator.
 * Uses the accent color to match the app's brand.
 */
.turbo-progress-bar {
  background-color: var(--color-accent);
}

/*
 * #nprogress — @inertiajs/core's page-navigation progress bar, the Inertia
 * pages' equivalent of the Turbo bar above. It injects its own <style> tag at
 * runtime with a hardcoded blue and a matching glow, and that tag lands in
 * <head> after this stylesheet has already loaded, so the override needs
 * !important to win regardless of when it shows up. One accent, one shadow
 * vocabulary: the vendor's second blue goes, and so does its glow.
 */
#nprogress .bar {
  background: var(--color-accent) !important;
}

#nprogress .peg {
  box-shadow: none !important;
}


/* ═══ Layout element defaults ═══ */

html {
  height: 100%;
}

body {
  height: 100%;
  background: var(--color-surface-body);
}


/* ═══ Toast notification animations ═══ */

/*
 * Transition classes for the flash notification toast (stimulus-use
 * useTransition). Applied/removed dynamically by the animation controller.
 *
 * Used by: app/views/application/_notification.html.erb
 */
.anim-toast-enter-active {
  transition: transform 300ms cubic-bezier(0, 0, 0.2, 1), opacity 300ms cubic-bezier(0, 0, 0.2, 1);
}

.anim-toast-enter-from {
  transform: translateY(0.5rem);
  opacity: 0;
}

@media (min-width: 40rem) {
  .anim-toast-enter-from {
    transform: translateY(0) translateX(0.5rem);
  }
}

.anim-toast-enter-to {
  transform: translateY(0) translateX(0);
  opacity: 1;
}

.anim-toast-leave-active {
  transition: opacity 100ms cubic-bezier(0.4, 0, 1, 1);
}

.anim-toast-leave-from {
  opacity: 1;
}

.anim-toast-leave-to {
  opacity: 0;
}

