/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* ─────────────────────────────────────────────────────────────────────
   Shared design tokens — the single color system for shy_hub and every
   engine mounted in it (dye, inventory, ...). Engine stylesheets alias
   their own historical variable names onto these in their :root blocks,
   so they inherit this palette (and its light/dark switch) for free.
   Only *color* tokens flip in dark mode; radius/shadow/type are shared.
   ───────────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light dark;

  /* Surfaces */
  --shy-bg:             #f4f6f8;  /* page background */
  --shy-surface:        #ffffff;  /* cards, panels */
  --shy-surface-alt:    #eef1f5;  /* headers, striping, quiet fills */
  --shy-surface-sunken: #e7ebf0;  /* inputs, wells */
  --shy-border:         #d8dde4;
  --shy-border-strong:  #c0c7d1;

  /* Text */
  --shy-text:        #1f2933;
  --shy-text-muted:  #52606d;
  --shy-text-faint:  #8a97a5;

  /* Brand — navy. The primary action + accent color everywhere. */
  --shy-brand:          #2b4c6f;
  --shy-brand-hover:    #22405d;
  --shy-brand-contrast: #ffffff;  /* text/icons on a brand-filled surface */
  --shy-brand-tint:     #e6edf4;  /* pale wash for active pills, hovers */
  --shy-brand-ring:     rgba(43, 76, 111, 0.30);  /* focus ring */

  /* Top nav chrome — stays dark navy in light mode, its own token so it
     doesn't track --shy-brand when that lightens for dark mode. */
  --shy-nav-bg: #2b4c6f;
  --shy-nav-fg: #ffffff;

  /* Semantic — each with a low-chroma tint for badge/callout backgrounds */
  --shy-danger:       #b3261e;
  --shy-danger-tint:  #fbe7e5;
  --shy-success:      #1e7a3c;
  --shy-success-tint: #e2f4e8;
  --shy-warning:      #8a5300;
  --shy-warning-tint: #fbeede;

  /* Radius */
  --shy-radius-sm: 4px;
  --shy-radius:    6px;
  --shy-radius-lg: 12px;

  /* Elevation */
  --shy-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shy-shadow:    0 1px 3px rgba(16, 24, 40, 0.10), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shy-shadow-md: 0 4px 12px rgba(16, 24, 40, 0.10), 0 2px 4px rgba(16, 24, 40, 0.06);

  /* Type */
  --shy-font:      -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --shy-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Trix's toolbar icons are black SVG data URIs baked into actiontext.css,
     so they can't be recoloured by a token -- they have to be inverted
     wholesale on dark. Kept here as a token so the two dark blocks below
     stay the single place where light/dark diverges. */
  --shy-icon-invert: none;
}

/* Dark palette. Applied two ways, kept in sync:
   - automatically when the OS asks for dark AND the user hasn't forced
     light via the nav toggle (:root:not([data-theme="light"]))
   - explicitly when the nav toggle forces dark (:root[data-theme="dark"])
   The nav toggle writes data-theme onto <html> (persisted in
   localStorage; see the inline script in layouts/application.html.erb). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shy-bg:             #12151a;
    --shy-surface:        #1b2027;
    --shy-surface-alt:    #232b34;
    --shy-surface-sunken: #0f1216;
    --shy-border:         #2e3742;
    --shy-border-strong:  #414c5b;

    --shy-text:        #e6eaf0;
    --shy-text-muted:  #a3adba;
    --shy-text-faint:  #6b7683;

    --shy-brand:          #6ea3d8;  /* lightened so it reads on dark */
    --shy-brand-hover:    #86b4e2;
    --shy-brand-contrast: #10141a;  /* dark text on the light-blue fill */
    --shy-brand-tint:     rgba(110, 163, 216, 0.16);
    --shy-brand-ring:     rgba(110, 163, 216, 0.40);

    --shy-nav-bg: #1b2027;
    --shy-nav-fg: #e6eaf0;

    --shy-danger:       #f0908a;
    --shy-danger-tint:  rgba(240, 144, 138, 0.15);
    --shy-success:      #6fd399;
    --shy-success-tint: rgba(111, 211, 153, 0.15);
    --shy-warning:      #e6b467;
    --shy-warning-tint: rgba(230, 180, 103, 0.15);

    --shy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
    --shy-shadow:    0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
    --shy-shadow-md: 0 6px 20px rgba(0, 0, 0, 0.50), 0 2px 6px rgba(0, 0, 0, 0.40);

    --shy-icon-invert: invert(1);
  }
}

:root[data-theme="dark"] {
  --shy-bg:             #12151a;
  --shy-surface:        #1b2027;
  --shy-surface-alt:    #232b34;
  --shy-surface-sunken: #0f1216;
  --shy-border:         #2e3742;
  --shy-border-strong:  #414c5b;

  --shy-text:        #e6eaf0;
  --shy-text-muted:  #a3adba;
  --shy-text-faint:  #6b7683;

  --shy-brand:          #6ea3d8;
  --shy-brand-hover:    #86b4e2;
  --shy-brand-contrast: #10141a;
  --shy-brand-tint:     rgba(110, 163, 216, 0.16);
  --shy-brand-ring:     rgba(110, 163, 216, 0.40);

  --shy-nav-bg: #1b2027;
  --shy-nav-fg: #e6eaf0;

  --shy-danger:       #f0908a;
  --shy-danger-tint:  rgba(240, 144, 138, 0.15);
  --shy-success:      #6fd399;
  --shy-success-tint: rgba(111, 211, 153, 0.15);
  --shy-warning:      #e6b467;
  --shy-warning-tint: rgba(230, 180, 103, 0.15);

  --shy-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
  --shy-shadow:    0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shy-shadow-md: 0 6px 20px rgba(0, 0, 0, 0.50), 0 2px 6px rgba(0, 0, 0, 0.40);

  --shy-icon-invert: invert(1);
}

body {
  font-family: var(--shy-font);
  background: var(--shy-bg);
  color: var(--shy-text);
  margin: 0;
}

.shy-main {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  min-width: 0;
}

/* ── App shell ───────────────────────────────────────────────────────
   Collapsible left sidebar for cross-engine navigation + a content
   column whose top bar carries the active engine's own navigation.
   Sidebar state lives in html[data-sidebar] ("collapsed"/"expanded"),
   persisted to localStorage and applied pre-paint by the inline script
   in layouts/application.html.erb. Default (no attr) = expanded. */
.shy-shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
  max-width: 100%;
}

.shy-sidebar {
  flex: 0 0 15rem;
  width: 15rem;
  align-self: stretch;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 0.75rem;
  background: var(--shy-nav-bg);
  color: var(--shy-nav-fg);
}

:root[data-sidebar="collapsed"] .shy-sidebar { display: none; }

.shy-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.35rem 0.75rem;
}

.shy-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--shy-nav-fg);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}

.shy-sidebar__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: var(--shy-radius);
  background: rgba(255, 255, 255, 0.14);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.shy-sidebar__collapse,
.shy-topbar__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--shy-radius);
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.shy-sidebar__collapse:hover { background: rgba(255, 255, 255, 0.12); }

.shy-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.shy-sidebar__link {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: var(--shy-radius);
  color: var(--shy-nav-fg);
  text-decoration: none;
  font-size: 0.92rem;
  opacity: 0.82;
}

.shy-sidebar__link:hover { background: rgba(255, 255, 255, 0.1); opacity: 1; }
.shy-sidebar__link.is-active { background: rgba(255, 255, 255, 0.16); opacity: 1; font-weight: 600; }

.shy-sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.shy-sidebar__action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: var(--shy-radius);
  color: var(--shy-nav-fg);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  opacity: 0.82;
  text-align: left;
}

.shy-sidebar__action:hover { background: rgba(255, 255, 255, 0.1); opacity: 1; }

.shy-sidebar__account {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: var(--shy-radius);
  text-decoration: none;
  color: var(--shy-nav-fg);
}

.shy-sidebar__account:hover { background: rgba(255, 255, 255, 0.1); }

.shy-sidebar__account-name { display: block; font-size: 0.9rem; }

.shy-sidebar__account-sub {
  display: block;
  font-size: 0.72rem;
  opacity: 0.6;
}

.shy-sidebar__signout { display: block; }

.shy-sidebar__signout button {
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--shy-radius);
  color: var(--shy-nav-fg);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}

.shy-sidebar__signout button:hover { background: rgba(255, 255, 255, 0.16); }

/* Theme toggle glyph — reflects the mode the click switches *to*. */
.shy-theme-icon::before { content: "\1F319"; }  /* crescent moon */
:root[data-theme="dark"] .shy-theme-icon::before { content: "\2600"; }  /* sun */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shy-theme-icon::before { content: "\2600"; }
}

.shy-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Wide content (big data tables, card grids) belongs in its own scroll
     container -- e.g. the engines' .table-scroll wrapper. Anything that
     still spills past the content column is clipped here instead of
     scrolling the whole page sideways. `clip` (not `hidden`/`auto`) so it
     doesn't turn this into a scroll container and break the sticky top
     bar; fixed overlays (sidebar, voice widget) escape it regardless. */
  overflow-x: clip;
}

/* Top bar — the active engine's own navigation, or the app title on
   host-level pages. Sticks to the viewport top on scroll. */
.shy-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.5rem;
  min-height: 3rem;
  background: var(--shy-surface);
  border-bottom: 1px solid var(--shy-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.shy-topbar__menu {
  border-color: var(--shy-border-strong);
  color: var(--shy-text-muted);
}

.shy-topbar__menu:hover { background: var(--shy-surface-alt); }

:root:not([data-sidebar="collapsed"]) .shy-topbar__menu { display: none; }

.shy-topbar__title { font-weight: 700; margin-right: auto; }

/* Wraps the engine sub-nav. Inline in the flow on desktop; a right-side
   slide-out drawer on narrow screens (toggled by .shy-topbar__section-menu,
   state in html[data-enginenav]). */
.shy-topbar__nav {
  flex: 1;
  min-width: 0;
  display: flex;
}

.shy-topbar__section-menu { display: none; }

/* Drawer header (engine name + close) — only shown when the nav is a
   slide-out on narrow screens. */
.shy-topbar__nav-head { display: none; }

/* Engine sub-navigation — lives in the top bar now. */
.shy-subnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.25rem;
}

.shy-subnav a {
  color: var(--shy-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.25rem 0;
}

.shy-subnav a:hover { color: var(--shy-brand); }

/* Off-canvas scrims (sidebar / engine-nav drawer), narrow screens only. */
.shy-scrim { display: none; }

@media (max-width: 820px) {
  .shy-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    /* 100dvh, not the base rule's 100vh: mobile browser UI (URL bar)
       otherwise makes the box taller than the visible area and pushes
       the footer (name + sign out) off-screen. overflow-y: auto on the
       base rule still scrolls if even this isn't enough. */
    height: 100dvh;
    z-index: 40;
    box-shadow: var(--shy-shadow-md);
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom));
  }

  :root:not([data-sidebar="collapsed"]) #shy-sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.45);
  }

  .shy-topbar {
    padding-inline: 1rem;
    justify-content: space-between;
  }

  .shy-main { padding: 1rem; }

  .shy-topbar__section-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: transparent;
    border: 1px solid var(--shy-border-strong);
    border-radius: var(--shy-radius);
    color: var(--shy-text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
  }

  .shy-topbar__section-menu:hover { background: var(--shy-surface-alt); }

  .shy-topbar__nav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 17rem;
    max-width: 84vw;
    z-index: 40;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--shy-surface);
    border-left: 1px solid var(--shy-border);
    box-shadow: var(--shy-shadow-md);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.2s ease;
  }

  :root[data-enginenav="open"] .shy-topbar__nav { transform: translateX(0); }

  .shy-topbar__nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0.9rem 0.85rem 1.1rem;
    border-bottom: 1px solid var(--shy-border);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--shy-text-faint);
  }

  .shy-topbar__nav-close {
    width: 1.9rem;
    height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--shy-radius);
    color: var(--shy-text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
  }

  .shy-topbar__nav-close:hover { background: var(--shy-surface-alt); color: var(--shy-text); }

  .shy-topbar__nav .shy-subnav {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.1rem;
    padding: 0.5rem;
  }

  .shy-topbar__nav .shy-subnav a {
    padding: 0.7rem 0.75rem;
    border-radius: var(--shy-radius);
    font-size: 0.95rem;
    color: var(--shy-text);
  }

  .shy-topbar__nav .shy-subnav a:hover {
    background: var(--shy-surface-alt);
    color: var(--shy-text);
  }

  .shy-topbar__nav .shy-subnav a:active {
    background: var(--shy-brand-tint);
    color: var(--shy-brand);
  }

  :root[data-enginenav="open"] #shy-enginenav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.5);
  }
}

/* Print: drop the whole app shell (sidebar, top bar, scrims) and let the
   page content flow from the top-left at full width. Engine stylesheets
   add their own print rules for the content itself. */
@media print {
  /* The app-wide sheet setup, and the ONLY @page rule that belongs in a
     shared stylesheet.

     @page is a page-context at-rule: it cannot be scoped by a selector, so
     `.engine-schedule @page { ... }` is not a thing. An engine that put one
     in its own stylesheet would silently set the paper for EVERY page in the
     app, because stylesheet_link_tag :all loads every engine's CSS
     everywhere. That is exactly what happened -- schedule's landscape rule
     turned the whole site landscape, dye's margins applied app-wide -- and
     it is invisible until someone prints an unrelated page.

     So: @page lives here. A page that genuinely needs different paper
     declares it via `content_for :page_style` in its own view, which the
     layout renders after this file. See engines/schedule/.../days/show. */
  @page {
    size: portrait;
    margin: 1.2cm 1.5cm;
  }

  .shy-sidebar,
  .shy-scrim,
  .shy-topbar {
    display: none !important;
  }

  .shy-shell { display: block; }

  .shy-content {
    display: block;
    overflow: visible;
  }

  .shy-main {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  /* A flash is a transient on-screen notice -- it is stale the moment it
     lands on paper, and it is the FIRST thing in .shy-main, so it pushed
     the real content the better part of an inch down the sheet (hit for
     real printing a training SOP straight after saving it). */
  .shy-flash { display: none !important; }

  body { background: #fff; }
}

.shy-flash {
  padding: 0.75rem 1rem;
  border-radius: var(--shy-radius);
  margin-bottom: 1rem;
}

.shy-flash--notice {
  background: var(--shy-success-tint);
  color: var(--shy-success);
}

.shy-flash--alert {
  background: var(--shy-danger-tint);
  color: var(--shy-danger);
}

.shy-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

/* The title block takes the slack and wraps its own text; below ~16rem of
   room for it the actions drop to their own line instead of being crushed
   into a narrow column. */
.shy-page-header > :first-child {
  flex: 1 1 16rem;
  min-width: 0;
}

/* Without this the actions are an unstyled block, so its buttons are just
   inline content -- they get no gap, and they break one-per-line as soon as
   the column is squeezed (which is what happens on any narrow screen). */
.shy-page-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  /* On its own line it must still wrap inside the screen: without a cap a
     non-shrinking flex item stays one long row and runs off a phone. */
  max-width: 100%;
}

.shy-page-header h1 {
  margin: 0;
}

.shy-page-header__subtitle {
  color: var(--shy-text-muted);
  margin: 0.25rem 0 0;
}

.shy-card {
  background: var(--shy-surface);
  border: 1px solid var(--shy-border);
  border-radius: var(--shy-radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.shy-card__title {
  margin-top: 0;
}

/* Deferred sections (Shared::DeferredSectionComponent, spec #120): the
   card's body fills in from its own URL. Until then a skeleton of grey
   bars about a short list's height, so the page doesn't jump much. */
.shy-deferred { display: block; }

.shy-deferred__skeleton {
  display: grid;
  gap: 0.6rem;
}

.shy-skeleton {
  display: block;
  height: 0.9rem;
  border-radius: var(--shy-radius-sm);
  background: linear-gradient(90deg, var(--shy-surface-alt) 0%, var(--shy-surface-sunken) 50%, var(--shy-surface-alt) 100%);
  background-size: 200% 100%;
  animation: shy-skeleton-shimmer 1.4s ease-in-out infinite;
}

.shy-skeleton--short { width: 60%; }

.shy-deferred__loading {
  color: var(--shy-text-faint);
  font-size: 0.85rem;
}

@keyframes shy-skeleton-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .shy-skeleton { animation: none; }
}

/* The section's service failed: "Couldn't reach ShipStation · Retry". */
.shy-deferred__error {
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--shy-radius);
  background: var(--shy-warning-tint);
  color: var(--shy-warning);
}

.shy-deferred__detail {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.shy-deferred__retry,
.shy-as-of__refresh {
  color: inherit;
  font-weight: 600;
}

/* "as of 4 min ago · Refresh" (Shared::AsOfComponent). */
.shy-as-of {
  color: var(--shy-text-muted);
  font-size: 0.85rem;
}

/* Admin → Slow pages: a request's section and route, under its path. */
.shy-slow__route {
  display: block;
  color: var(--shy-text-muted);
  font-size: 0.8rem;
}

/* Hub dashboard: one card per engine, each engine rendering its own
   application/_hub_card partial. */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

@media (max-width: 960px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

.dashboard-grid .shy-card { margin-bottom: 0; }

.hub-card__section { margin-bottom: 1rem; }
.hub-card__section:last-of-type { margin-bottom: 0; }

.hub-card__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--shy-text-faint);
  margin-bottom: 0.45rem;
}

.hub-card__label a { color: inherit; }

.hub-card__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hub-card__list li { font-size: 0.9rem; }

.hub-card__meta {
  color: var(--shy-text-muted);
  font-size: 0.8rem;
  margin-left: 0.35rem;
}

.hub-card__tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--shy-surface-alt);
  color: var(--shy-text-muted);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.hub-card__empty {
  color: var(--shy-text-muted);
  font-size: 0.9rem;
  margin: 0.1rem 0 0;
}

.hub-card__foot {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--shy-border);
  font-size: 0.85rem;
}

.hub-card__foot a { color: var(--shy-brand); }

.shy-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--shy-radius);
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

.shy-btn--primary {
  background: var(--shy-brand);
  color: var(--shy-brand-contrast);
}

.shy-btn--secondary {
  background: var(--shy-surface);
  color: var(--shy-text);
  border: 1px solid var(--shy-border-strong);
}

.shy-btn--danger {
  background: var(--shy-danger);
  color: var(--shy-brand-contrast);
}

/* Every table sits in one of these (or an engine's own scroll wrapper):
   a table wider than a phone scrolls sideways inside it instead of being
   cut off by .shy-content's overflow clip. Printed pages show it whole. */
.shy-table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

@media print {
  .shy-table-scroll { overflow: visible; }
}

/* Long unbroken strings (URLs, OAuth scopes) wrap instead of running off. */
.shy-main code { overflow-wrap: anywhere; }

/* Baseline form + table styling for host-level pages (e.g. Admin::*),
   scoped under .shy-admin rather than bare element/class selectors --
   engine pages render inside the same .shy-main wrapper and bring their
   own (differently-styled) unscoped `table`/`.field`/`.actions` rules in
   their own stylesheets; unscoped rules here would leak into every
   engine page too via `stylesheet_link_tag :all` and fight with those. */
.shy-admin .field {
  margin-bottom: 1rem;
}

.shy-admin .field label {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.shy-admin .field input,
.shy-admin .field select,
.shy-admin .field textarea {
  width: 100%;
  max-width: 24rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--shy-border-strong);
  border-radius: var(--shy-radius);
  background: var(--shy-surface);
  color: var(--shy-text);
  font: inherit;
}

.shy-admin .field small {
  display: block;
  margin-top: 0.3rem;
  color: var(--shy-text-muted);
  font-size: 0.8rem;
}

.shy-admin .actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1.25rem;
}

.shy-admin .actions input[type="submit"] {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--shy-radius);
  background: var(--shy-brand);
  color: var(--shy-brand-contrast);
  font: inherit;
  cursor: pointer;
}

.shy-admin table {
  width: 100%;
  border-collapse: collapse;
}

.shy-admin th,
.shy-admin td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--shy-border);
  font-size: 0.9rem;
}

.shy-admin th {
  color: var(--shy-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Sub-section heading inside an .shy-admin form (e.g. the account page's
   "Change password" group). */
.shy-account__section {
  margin: 1.75rem 0 0.25rem;
  font-size: 0.95rem;
}

.shy-account__hint {
  margin: 0 0 0.85rem;
  color: var(--shy-text-muted);
  font-size: 0.85rem;
}

/* Unauthenticated pages (sign in, forgot/reset password). These render
   inside .shy-main with no top nav, so the card centers itself in the
   viewport rather than sitting flush at the top-left. */
.shy-auth {
  min-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 2rem 0;
}

.shy-auth__brand {
  text-align: center;
}

.shy-auth__brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--shy-brand);
  letter-spacing: -0.01em;
}

.shy-auth__brand-tagline {
  margin-top: 0.25rem;
  color: var(--shy-text-muted);
  font-size: 0.9rem;
}

.shy-auth__card {
  width: 100%;
  max-width: 22rem;
  background: var(--shy-surface);
  border: 1px solid var(--shy-border);
  border-radius: var(--shy-radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shy-shadow-md);
}

.shy-auth__card h1 {
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
}

.shy-auth__field {
  margin-bottom: 1rem;
}

.shy-auth__field label {
  display: block;
  font-weight: 500;
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
  color: var(--shy-text-muted);
}

.shy-auth__field input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--shy-border-strong);
  border-radius: var(--shy-radius);
  font: inherit;
  box-sizing: border-box;
  background: var(--shy-surface);
  color: var(--shy-text);
}

.shy-auth__field input:focus {
  outline: none;
  border-color: var(--shy-brand);
  box-shadow: 0 0 0 3px var(--shy-brand-ring);
}

.shy-auth__submit {
  width: 100%;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--shy-radius);
  background: var(--shy-brand);
  color: var(--shy-brand-contrast);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.25rem;
}

.shy-auth__submit:hover {
  background: var(--shy-brand-hover);
}

.shy-auth__foot {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
}

.shy-auth__foot a {
  color: var(--shy-brand);
}

/* ============================================================
 * ActionText / Trix
 *
 * actiontext.css is Rails' STOCK generated file and hardcodes a light
 * palette throughout (#fff surfaces, #bbb borders, #333 text) plus black
 * SVG toolbar icons. Left alone it is unreadable in dark mode -- white
 * boxes on a dark page, invisible icons.
 *
 * These overrides live in the HOST, not in an engine, for two reasons:
 * it's a framework-level styling concern rather than anything Training
 * owns, and dye's technique editor uses the same widget and had the same
 * bug. Per CLAUDE.md: change colours in the host file.
 *
 * They rely on `:all` loading actiontext.css before application.css
 * (alphabetical, and Propshaft is stable here), but every rule below is
 * also specific enough to win on its own -- don't reduce the selectors to
 * bare element names on the assumption that ordering will save them.
 * ============================================================ */

trix-editor {
  background: var(--shy-surface);
  color: var(--shy-text);
  border: 1px solid var(--shy-border-strong);
  border-radius: var(--shy-radius);
  padding: 0.75rem;
}

trix-editor:empty::before {
  color: var(--shy-text-faint);
}

trix-editor:focus,
trix-editor:focus-visible {
  outline: 2px solid var(--shy-brand-ring);
  outline-offset: 1px;
  border-color: var(--shy-brand);
}

/* --- toolbar ------------------------------------------------------- */

trix-toolbar {
  background: var(--shy-surface-alt);
  border: 1px solid var(--shy-border);
  border-bottom: none;
  border-radius: var(--shy-radius) var(--shy-radius) 0 0;
  padding: 0.25rem 0.4rem;
}

/* The editor sits directly under its toolbar; square off the seam. */
trix-toolbar + trix-editor {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

trix-toolbar .trix-button-group {
  border: 1px solid var(--shy-border-strong);
  background: var(--shy-surface);
  border-radius: var(--shy-radius-sm);
}

trix-toolbar .trix-button-group:not(:first-child) {
  border-left: 1px solid var(--shy-border-strong);
}

trix-toolbar .trix-button {
  background: transparent;
  color: var(--shy-text-muted);
  border-bottom: none;
}

trix-toolbar .trix-button:not(:first-child) {
  border-left: 1px solid var(--shy-border);
}

trix-toolbar .trix-button:not(:disabled):hover {
  background: var(--shy-brand-tint);
  color: var(--shy-text);
}

trix-toolbar .trix-button.trix-active {
  background: var(--shy-brand-tint);
  color: var(--shy-brand);
}

/* The one thing a colour token can't reach: the icons are black SVG data
   URIs baked into actiontext.css, so on dark they have to be inverted
   whole. --shy-icon-invert is `none` in light, `invert(1)` in dark. */
trix-toolbar .trix-button--icon::before {
  filter: var(--shy-icon-invert);
}

/* --- link dialog --------------------------------------------------- */

trix-toolbar .trix-dialog {
  background: var(--shy-surface);
  border-top: 2px solid var(--shy-border-strong);
  box-shadow: var(--shy-shadow-md);
  color: var(--shy-text);
}

trix-toolbar .trix-dialog .trix-input--dialog {
  background: var(--shy-surface);
  color: var(--shy-text);
  border: 1px solid var(--shy-border-strong);
  border-radius: var(--shy-radius-sm);
  font: inherit;
  padding: 0.35rem 0.5rem;
}

trix-toolbar .trix-dialog .trix-button--dialog {
  background: var(--shy-surface-alt);
  color: var(--shy-text);
  border: 1px solid var(--shy-border-strong);
  border-radius: var(--shy-radius-sm);
}

/* --- attachments (in the editor AND in rendered output) ------------- */

.trix-content .attachment {
  max-width: 100%;
}

.trix-content .attachment img {
  max-width: 100%;
  height: auto;
}

.trix-content .attachment__caption {
  color: var(--shy-text-muted);
  font-size: 0.8125rem;
  text-align: center;
}

/* A non-image attachment (PDF, doc) renders as a caption with no preview;
   give it a visible body so it doesn't read as an empty gap. */
.trix-content .attachment--file {
  border: 1px solid var(--shy-border-strong);
  border-radius: var(--shy-radius);
  padding: 0.5rem 0.75rem;
  background: var(--shy-surface-alt);
}

.trix-content .attachment__name { color: var(--shy-text); font-weight: 600; }
.trix-content .attachment__size { color: var(--shy-text-muted); margin-left: 0.4rem; }

/* Trix's own progress/caption chrome while an upload is in flight. */
.trix-content .attachment__progress {
  background: var(--shy-brand-tint);
}

/* Christmas party survey (/party). Throwaway: delete with the page. */
.shy-party fieldset.shy-party__question { border: 0; margin: 0 0 1.25rem; padding: 0; min-width: 0; }
.shy-party__question legend { font-weight: 600; padding: 0; margin-bottom: 0.6rem; }
.shy-party__question .shy-account__hint { margin-top: -0.35rem; }
.shy-party__choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.shy-party__choice { position: relative; cursor: pointer; }
.shy-party__choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.shy-party__choice span {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--shy-border-strong); border-radius: var(--shy-radius);
  background: var(--shy-surface);
}
.shy-party__choice span::before {
  content: ""; width: 0.85rem; height: 0.85rem; border-radius: 50%;
  border: 1.5px solid var(--shy-text-muted);
}
.shy-party__choice:hover span { border-color: var(--shy-brand); }
.shy-party__choice input:checked + span { border-color: var(--shy-brand); background: var(--shy-brand-tint); }
.shy-party__choice input:checked + span::before { border-color: var(--shy-brand); background: var(--shy-brand); box-shadow: inset 0 0 0 2px var(--shy-surface); }
.shy-party__choice input:focus-visible + span { outline: 2px solid var(--shy-brand); outline-offset: 2px; }
.shy-party .field textarea { max-width: 36rem; }
.shy-party__inline { margin: 0; font-weight: 400; }
.shy-party__tallies { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.25rem; }
.shy-party__bar { display: grid; grid-template-columns: 4rem 1fr 2rem; align-items: center; gap: 0.6rem; font-size: 0.9rem; margin-bottom: 0.35rem; }
.shy-party__track { height: 0.55rem; border-radius: 999px; background: var(--shy-border); overflow: hidden; }
.shy-party__fill { display: block; height: 100%; background: var(--shy-brand); border-radius: 999px; }
.shy-party__n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.shy-party__thought { white-space: pre-wrap; overflow-wrap: anywhere; }
.shy-party__missing { margin-top: 0.85rem; }
