
/* Reset */
* {
  box-sizing: border-box;
}

button {
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

/* Body */
body {
  margin: 0;
  background: radial-gradient(circle at top, rgba(76, 0, 128, 0.25), transparent 50%),
              radial-gradient(circle at 15% 20%, rgba(60, 194, 255, 0.2), transparent 35%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* App Shell Layout */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xl);
  background: rgba(3, 5, 12, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  z-index: 100;
}

.app-main {
  flex: 1;
  padding: var(--space-xl) clamp(1rem, 4vw, 4rem) var(--space-2xl);
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem var(--space-2xl);
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(3, 5, 12, 0.5);
}

/* Build info pill — fixed bottom-right corner */
.build-pill {
  appearance: none;
  position: fixed;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 18, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 3px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  /* PR fix/post-deploy-bundle (a11y): #64748b on dark surface measured 3.98
     contrast. Tailwind slate-400 (#94a3b8) clears 4.5:1 on the build-pill bg. */
  color: var(--palette-slate-400);
  cursor: pointer;
  z-index: 9999;
  user-select: none;
  backdrop-filter: blur(6px);
  transition: background 0.15s;
}
.build-pill:hover { background: rgba(15, 18, 30, 0.95); color: var(--palette-slate-400); }
.build-pill .build-pill-detail { display: none; }
.build-pill.expanded .build-pill-short { display: none; }
.build-pill.expanded .build-pill-detail { display: inline; }

/* Logo Block */
.logo-block {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  flex-shrink: 0;
}

.glyph {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent), var(--accent-hot));
  display: grid;
  place-items: center;
  font-weight: 600;
}

.logo-symbol {
  height: 42px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.logo-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.logo-genie {
  color: var(--accent);
}

.logo-sub {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Hero Section */
.hero {
  margin-bottom: var(--space-xl);
  position: relative;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: var(--space-sm);
}

.hero p {
  color: var(--text-dim);
  max-width: 640px;
}

.hero-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: var(--space-sm);
}

/* Status Text */
.status-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
}

/* Utility Classes */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }

.mono {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Gradient Border Mixin (via pseudo-element) */
.gradient-border::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(60, 194, 255, 0.35), rgba(255, 79, 216, 0.25));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Stacked Panel */
.stacked-panel {
  margin-top: var(--space-xl);
  background: var(--card);
  border-radius: 20px;
  padding: var(--space-xl);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Empty State */
/*
 * THE SECOND LINE OF AN EMPTY STATE, which is a hint and not another paragraph.
 *
 * `.hint` was styled ONLY as `.widget-needs-config .hint` in widget-base.css, and four of its
 * five users are widgets that do emit that wrapper. The fifth — `screen-section.js`, which says
 * «That is a coverage gap, not a market reading» under a «no symbol carries this signal yet»
 * line — puts it inside `.empty-state`, where the rule could never match: it rendered at the
 * same size and opacity as the sentence above it, so the distinction between the fact and the
 * caveat was invisible.
 *
 * Declared on the PRIMITIVE rather than scoped to that one page, for the reason the comment
 * below gives about colour: a hint inside an empty state is the same thing everywhere, and the
 * ninth page to need it should not be the ninth place it is written. Found 2026-11-27 by the
 * check in tests/hygiene/section-classes-defined.test.mjs, extended to the scoped-only case.
 */
.empty-state .hint {
  font-size: 0.8125rem;
  opacity: 0.6;
  margin-top: var(--space-sm);
}

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);

  /*
   * The colour belongs HERE, not on ten pages. Nine page stylesheets each added
   * `color: var(--text-dim)` to this selector because the primitive did not carry it,
   * which is what `css.primitive-selector-redefinitions` was counting. The sibling rule
   * below says these two have "the same footprint", and .loading-state has been dim all
   * along — so dim was always the intent and the primitive was simply incomplete.
   *
   * ai-studio.css was the one page that never set it and therefore rendered BRIGHT
   * (measured: rgb(245,247,255) against .loading-state's rgb(203,213,225)). It now
   * states `color: var(--text)` explicitly, so this addition changes nothing anywhere
   * and its divergence is a line someone can review instead of an omission.
   */
  color: var(--text-dim);
}

.empty-state h3 {
  margin: 0 0 var(--space-sm);
  font-size: 1.25rem;
}

.empty-state p {
  color: var(--text-dim);
  margin: 0 0 var(--space-sm);
}

/*
 * ── Navigation ────────────────────────────────────────────────────────────────
 *
 * Every tab in the platform bar is an <a> to its own URL, so switching tab is a FULL
 * DOCUMENT NAVIGATION: the browser tears down one document and paints the next, and the gap
 * between them is the white flash reported as "navigating flickers the whole page" on
 * 25.11.2026. No class applied after render can cover that — trying is how a second flicker
 * got added on top of the first the same day.
 *
 * This is the actual fix, and it is one at-rule: the browser captures the outgoing document,
 * holds it while the next one prepares, and cross-fades. It needs BOTH documents to opt in
 * and the navigation to be same-origin — `base.css` is linked by `_CoreCss.cshtml` on every
 * page, so every internal navigation qualifies and no page needs to know about it.
 *
 * Unsupported browsers ignore the at-rule entirely and navigate exactly as they do today.
 * There is no polyfill, no JS, and nothing to clean up.
 *
 * WHAT IT DOES NOT FIX, stated so nobody reads more into it: the tab sections render their
 * content from the client after the document loads, so the incoming snapshot is that tab's
 * loading state, not its table. The flash between documents is gone; the loading-to-content
 * step is a separate thing, and the answer to that one was making the content fast.
 */
@view-transition {
  navigation: auto;
}

/*
 * 140 ms, not the 250 ms default. A tab switch is a small move inside one surface and the
 * shell either side of it is identical, so the cross-fade only has to hide the hand-off —
 * long enough to read as a transition, short enough that it never reads as waiting.
 */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 140ms;
}

/*
 * The whole point of the setting. A cross-fade of the entire viewport is exactly the kind of
 * motion it asks to be spared, and without the animation the navigation is simply the instant
 * swap it was before.
 */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* Loading State — rendered by Pages/Shared/_LoadingState.cshtml; same footprint as .empty-state */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  color: var(--text-dim);
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
}

/*
 * A loading state that does not move reads as a page that has stopped, not one that is
 * working — which is what "instant page loading looks tacky" was about on 25.11.2026. The
 * pulse is the SAME animation the widget skeleton has used since H28
 * (`widgets/widget-base.css#skeleton-pulse`), lifted here because `base.css` is the one
 * stylesheet every page links and the widget sheet is not. One definition, not two: the
 * widget rule now reuses these keyframes.
 *
 * Behind `prefers-reduced-motion` because a pulsing block is exactly what that setting is
 * for; without the preference the state is simply still, which is what it was before.
 */
@keyframes tg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/*
 * The curve STARTS and ENDS at full opacity, which is not cosmetic. An animation whose 0 %
 * frame differs from the element's resting opacity steps to that frame the instant it begins
 * — the same manufactured flicker that a post-paint fade caused here on 25.11.2026, in a
 * quieter form. Starting at rest means the element dims and recovers, and the first frame
 * changes nothing.
 *
 * The delay is the other half: a load that resolves quickly should not animate at all. Below
 * 400 ms a reader does not perceive waiting, so a pulse there is motion for its own sake —
 * and three visual states (navigate, pulse, content) for a fast tab is what "flickers" means.
 * With no fill mode the element simply sits at its resting opacity until the delay elapses.
 */
@media (prefers-reduced-motion: no-preference) {
  .loading-state { animation: tg-pulse 1.5s ease-in-out 400ms infinite; }
}

/* Code Block */
.code-block {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 0.75rem var(--space-md);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  margin-top: var(--space-md);
}

/* Alert Styles */
.alert {
  padding: 0.85rem var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-size: 0.875rem;
}

.alert-success {
  background: rgba(96, 247, 168, 0.1);
  border: 1px solid rgba(96, 247, 168, 0.25);
  color: var(--success);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.alert-warning {
  background: rgba(250, 204, 21, 0.1);
  border: 1px solid rgba(250, 204, 21, 0.25);
  color: var(--warning);
}

/* Shared styled select dropdowns (used on Signal Studio, Observability, etc.) */
.toolbar-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: rgba(255, 255, 255, 0.04);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 4L5 6.5L7.5 4' stroke='rgba(255,255,255,0.5)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-full, 9999px);
  padding: 0 2.2rem 0 1rem;
  height: 36px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  box-sizing: border-box;
  min-width: 130px;
  max-width: 200px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.toolbar-select:hover {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(60, 194, 255, 0.4);
}

.toolbar-select:focus {
  outline: none;
  border-color: rgba(60, 194, 255, 0.6);
  background-color: rgba(60, 194, 255, 0.08);
}

.toolbar-select option {
  background: var(--card-bg);
  color: var(--palette-slate-100);
  padding: 0.5rem;
}

.toolbar-select optgroup {
  background: #12121f;
  color: var(--palette-slate-500);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem;
}

.toolbar-select option:checked {
  background: var(--accent);
  color: #ffffff;
}

/* =============================================================================
   Responsive — Hamburger, Header, Shell
   ============================================================================= */

/* Mobile Nav Toggle (hamburger) — hidden on desktop */
.mobile-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.2s ease;
  transform-origin: center;
}

/* Hamburger → X animation */
.mobile-nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.mobile-nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.mobile-nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile labels — hidden on desktop, shown in mobile nav drawer */
.mobile-label {
  display: none;
}

/* Header Nav Group — desktop: transparent wrapper */
.header-nav-group {
  display: contents;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* ---- Tablet & below (≤768px) ---- */
@media (max-width: 768px) {
  /* Mobile: header-actions becomes invisible so items flow into drawer */
  .header-actions {
    display: contents;
  }

  /* #9: Prevent iOS auto-zoom on input focus — all text inputs must be ≥16px */
  .app-shell input[type="text"],
  .app-shell input[type="search"],
  .app-shell input[type="email"],
  .app-shell input[type="password"],
  .app-shell input[type="number"],
  .app-shell input[type="url"],
  .app-shell input[type="tel"],
  .app-shell input:not([type]),
  .app-shell select,
  .app-shell textarea {
    font-size: 1rem;
  }

  .mobile-nav-toggle {
    display: flex;
  }

  .app-header {
    padding: var(--space-sm) var(--space-md);
    padding-top: calc(var(--space-sm) + env(safe-area-inset-top, 0px));
    z-index: 1010;
    /* backdrop-filter creates a containing block that traps position:fixed
       children (nav drawer) inside the header — disable on mobile */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(3, 5, 12, 0.95);
  }

  .logo-sub {
    display: none;
  }

  .glyph {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
    border-radius: var(--radius-md);
  }

  .logo-symbol { height: 34px; }

  .logo-title {
    font-size: 0.95rem;
  }

  .app-main {
    padding: var(--space-md) var(--space-sm) var(--space-lg);
    padding-left: calc(var(--space-sm) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--space-sm) + env(safe-area-inset-right, 0px));
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero-actions {
    position: static;
    margin-top: var(--space-sm);
    flex-wrap: wrap;
  }

  .app-footer {
    padding: 0.5rem var(--space-md);
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    font-size: 0.7rem;
  }

  .build-pill {
    font-size: 0.6rem;
    padding: 2px 8px;
  }

  .stacked-panel {
    padding: var(--space-md);
    border-radius: var(--radius-md);
  }

  .toolbar-select {
    min-width: 0;
    max-width: none;
    flex: 1;
  }
}

/* ---- Phone (≤480px) ---- */
@media (max-width: 480px) {
  .app-header {
    padding: var(--space-xs) var(--space-sm);
    gap: var(--space-sm);
  }

  .glyph {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
  }

  .logo-symbol { height: 30px; }

  .logo-title {
    font-size: 0.85rem;
  }

  .app-main {
    padding: var(--space-sm) var(--space-xs) var(--space-md);
  }

  .hero h1 {
    font-size: 1.25rem;
  }

  .stacked-panel {
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
  }
}

/* Present to assistive technology, absent on screen.
   Added 2026-11-18 with the menu's parity dots. The dot carries the state visually, and
   `title` is not a substitute for anyone not using a pointer — it never reaches a keyboard
   user and screen-reader support for it is inconsistent. The markup already referenced this
   class before it existed, so the state rendered as literal text beside every tab label and
   pushed the row into a horizontal scroll. The clip-rect pair is the long-standing version
   that survives being inside a flex container, which `display: none` and `visibility:
   hidden` do not, because both remove the node from the accessibility tree too. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
