/* Geopatra suite shell — Step 33.
 *
 * Defines brand-level CSS variables (used by every tool) and the
 * collapsible sidebar layout. Tool-specific styles live in each tool's
 * own stylesheet and inherit these vars by cascade.
 *
 * Brand vars were lifted out of static/style.css unchanged; the audit
 * stylesheet keeps its own :root block aliasing back into these so
 * audit-only var names continue to resolve.
 */

:root {
  /* --- Geopatra brand (sampled from Logo_Geopatra.png) ------------ */
  --color-brand-yellow:       #F8C630;
  --color-brand-yellow-soft:  rgba(248, 198, 48, 0.18);
  /* Same-hue darken of the gold #F8C630 (hue ~45deg) for the hover of
   * every gold-fill control. The old #e8cf00 was the hover for the
   * retired #FEDF16 yellow — a different, limey hue (~53deg) — which
   * made gold buttons SHIFT colour on hover. This keeps the hue and
   * just presses it darker, suite-wide via this single token. */
  --color-brand-yellow-hover: #e6b829;
  --color-brand-navy:         #303851;

  /* --- Interim CI tokens (rolling out across the suite; introduced in
   *     the auth/login redesign). Distinct from the legacy brand-yellow
   *     above. Gradient is reserved for the 1-3 most important things
   *     (active nav item, hero icon tiles) — not every element. --- */
  --gold:           #F8C630;
  --magenta:        #d4459a;
  --hero-gradient:  linear-gradient(95deg, #d4459a, #F8C630);
  --brand-gradient: linear-gradient(135deg, #d4459a 0%, #9D487E 25%, #c0397f 50%, #F8C630 100%);

  /* --- Neutral CI surface + text stack (interim CI) --------------- *
   * SINGLE SOURCE OF TRUTH for both the login (auth_base.html) and the
   * app shell. Neutral BLACK — no blue/navy tint — so the magenta->gold
   * gradients and gold accents read crisply. The login pulls these same
   * tokens (its inline block only keeps auth-specific knobs), so login
   * and app can never drift in background tone. */
  /* LOGIN stays pure black (dramatic). WORKING pages use the CHARCOAL
   * stack: page #141417, sidebar #1c1c22, raised card #232329 (clearly
   * LIGHTER than the page so cards pop), fields #0d0d10 (darker than the
   * page = inset). Neutral black family — no blue/navy tint. */
  --bg-page:    #000000;   /* outermost page bg (LOGIN backdrop only) */
  --bg-app:     #141417;   /* working dashboard page base (charcoal) */
  --bg-sidebar: #1c1c22;   /* sidebar / panels */
  --bg-field:   #0d0d10;   /* inputs (darker than page = inset) */
  --bg-card:    #232329;   /* raised card surface (lighter than page) */
  --bg-card-lg: #121215;   /* large framed cards (empty-state, etc.) */
  --text-primary: #ffffff;
  --text-muted:   #9a9a9f;
  --text-faint:   #7c7c82;
  --border-subtle:   rgba(255, 255, 255, 0.08);
  --border-emphasis: rgba(255, 255, 255, 0.18);

  /* --- App surface aliases (legacy --color-* names map onto the
   *     neutral stack above; tools reference these by cascade). --- */
  --color-bg:        var(--bg-app);
  --color-surface:   var(--bg-card);
  --color-surface-2: #2a2a30; /* neutral tile, one notch lighter than card */
  --color-sidebar:   var(--bg-sidebar);
  --color-border:    var(--border-subtle);
  --color-text:      var(--text-primary);
  --color-text-dim:  var(--text-muted);

  /* --- Semantic data colors (success / warning / danger + coral +
   *     neutral). Tokenized from the values already scattered through
   *     the Analysis screen so this is a tokenization pass, not a
   *     recolor. Each has a solid stroke, a lighter text variant (for
   *     legibility on the dark theme), and a faint full-row tint.
   *     Brand yellow is NOT in this set — it is reserved for primary
   *     actions and must NEVER mean "good" (use success/green). ---  */
  --color-success:      rgb(16, 185, 129);
  --color-success-text: rgb(52, 211, 153);
  --color-success-tint: rgba(16, 185, 129, 0.12);
  --color-warning:      rgb(234, 179, 8);
  --color-warning-text: rgb(250, 204, 21);
  --color-warning-tint: rgba(234, 179, 8, 0.12);
  --color-danger:       rgb(239, 68, 68);
  --color-danger-text:  rgb(248, 113, 113);
  --color-danger-tint:  rgba(239, 68, 68, 0.12);
  /* Coral — the High / Major rung between danger-red and warning-amber. */
  --color-coral:        rgb(251, 113, 90);
  --color-coral-text:   rgb(253, 142, 120);
  --color-coral-tint:   rgba(251, 113, 90, 0.12);
  /* Neutral — Low / Polish severities + "no data" bands. */
  --color-neutral:      rgb(148, 163, 184);
  --color-neutral-text: rgb(148, 163, 184);
  --color-neutral-tint: rgba(148, 163, 184, 0.10);

  /* --- Sidebar geometry. Widened to 248px (was 220) — 212/220 felt
   *     too thin/cramped for the project tile + nav labels. --- */
  --sidebar-width-expanded:  248px;
  --sidebar-width-collapsed: 56px;
  --sidebar-transition:      200ms ease;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- Shell layout (sidebar + main) ----------------------------- */

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0; /* allow inner content to shrink past intrinsic width */
  display: flex;
  flex-direction: column;
}

/* ---- Shared top bar -------------------------------------------- *
 * The account avatar (and any page-injected top-right items) live
 * here in normal flow. ONE flex row: optional left slot + a right
 * group whose children are all flex-shrink:0, so the avatar and a
 * page's project badge reflow together and never overlap. */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  min-height: 44px;
}
.app-topbar-left {
  flex: 1;
  min-width: 0; /* page chrome here truncates instead of pushing the right group */
}
.app-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.app-topbar-right > * {
  flex-shrink: 0;
}
.app-main-content {
  flex: 1;
  min-width: 0;
}

/* ---- Sidebar --------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width-expanded);
  flex-shrink: 0;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 16px 8px 12px;
  box-sizing: border-box;
  transition: width var(--sidebar-transition);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.app-shell[data-sidebar-collapsed="true"] .sidebar {
  width: var(--sidebar-width-collapsed);
}

/* Logo: two images stacked behind a CSS cross-fade. Expanded sidebar
 * shows the wide wordmark; collapsed sidebar swaps to the square
 * favicon ("g" tile) so the brand stays chunky and centered at 56px
 * sidebar width. Both images live in the same flex slot and toggle
 * via opacity (with position:absolute on the inactive one) so the
 * swap animates smoothly during the sidebar width transition. */
.sidebar-logo {
  position: relative;
  height: 40px;
  margin: 0 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-img {
  display: block;
  transition: opacity var(--sidebar-transition);
}

.sidebar-logo-wordmark {
  height: 32px;
  width: auto;
  opacity: 1;
}

.sidebar-logo-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 32px;
  width: 32px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
}

.app-shell[data-sidebar-collapsed="true"] .sidebar-logo-wordmark {
  opacity: 0;
}

.app-shell[data-sidebar-collapsed="true"] .sidebar-logo-mark {
  opacity: 1;
}

/* ---- Tool list ------------------------------------------------- */

.sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-tool {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--color-text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  position: relative;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  user-select: none;
}

.sidebar-tool:hover:not(.is-disabled):not(.is-active) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text);
}

/* Active nav item: a gradient LEFT BAR + a very faint gradient tint
   (NOT a full gradient fill — that read too strong). The SAME treatment
   is used on the current-project tile so "active" and "current" share
   one visual language across the app. overflow:hidden clips the bar's
   corners to the item's border-radius. White label, gold icon. */
.sidebar-tool.is-active {
  overflow: hidden;
  background: linear-gradient(95deg, rgba(212, 69, 154, 0.12), transparent);
  color: #ffffff;
}
.sidebar-tool.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #d4459a, #F8C630);
}
.sidebar-tool.is-active .sidebar-tool-icon {
  color: var(--gold);
}

.sidebar-tool.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sidebar-tool-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: currentColor;
}

.sidebar-tool-label {
  flex: 1;
  opacity: 1;
  transition: opacity 150ms ease;
}

.app-shell[data-sidebar-collapsed="true"] .sidebar-tool-label {
  opacity: 0;
  pointer-events: none;
}

.sidebar-tool-badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  transition: opacity 150ms ease;
}

.app-shell[data-sidebar-collapsed="true"] .sidebar-tool-badge {
  opacity: 0;
  pointer-events: none;
}

/* ---- Spacer + bottom toggle ----------------------------------- */

.sidebar-spacer {
  flex: 1;
}

.sidebar-toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-dim);
  border-radius: 6px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 120ms ease, color 120ms ease;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text);
}

.sidebar-toggle-icon {
  display: inline-block;
  font-size: 18px;
  line-height: 1;
  transition: transform var(--sidebar-transition);
}

.app-shell[data-sidebar-collapsed="true"] .sidebar-toggle-icon {
  transform: rotate(180deg);
}

/* ---- Sidebar project context (Step 35) ------------------------ */

.sidebar-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0 4px 12px;
}

.sidebar-project-context {
  padding: 0 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 150ms ease;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

/* "Current project" tile — SAME active treatment as the active nav
 * item (gradient left bar + faint tint) so the two read consistently. */
.sidebar-project-current {
  position: relative;
  overflow: hidden;
  display: flex;
  /* Step 38: row layout so the favicon sits inline-left of the
   * stacked name+domain text. Step 37 used flex-direction:column;
   * the inner text now lives in .sidebar-project-text which keeps
   * the original vertical stack. */
  flex-direction: row;
  align-items: center;
  gap: 10px;
  /* Bigger tile that fills the (now wider) sidebar panel width. */
  padding: 10px 11px;
  background: linear-gradient(95deg, rgba(212, 69, 154, 0.12), transparent);
  border-radius: 9px;
}
.sidebar-project-current::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #d4459a, #F8C630);
}

/* Project mark inside the sidebar tile — 40px (the shared
 * `.project-favicon` base is 20px; this scopes the larger size +
 * radius to the sidebar). Works for both the --logo and --initial
 * variants emitted by the project_mark macro. */
.sidebar-project-current .project-favicon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
}

.sidebar-project-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0; /* allow truncation in the name/domain children */
  flex: 1;
}

.sidebar-project-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-project-domain {
  font-size: 11px;
  color: var(--color-text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Label + Switch share one row (label left, switch right-aligned). */
.sidebar-project-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-project-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  text-decoration: none;
  padding: 0;
  flex-shrink: 0;
}

.sidebar-project-switch:hover {
  text-decoration: underline;
}

.sidebar-project-cta {
  display: inline-block;
  background: var(--color-brand-yellow-soft);
  color: var(--color-brand-yellow);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
  text-align: center;
}

.sidebar-project-cta:hover {
  background: rgba(248, 198, 48, 0.28);
}

/* ---- Account menu (top-right avatar + dropdown) ---------------- */
/* Replaces the Phase 1 sidebar account block. Fixed to the top-right
 * corner so it sits in the same spot on every tool page. z-index sits
 * above page content but BELOW the project modal (z-index 1000), so an
 * open modal cleanly covers it. */
/* In-flow flex item inside .app-topbar-right (was position:fixed). The
 * relative position keeps the absolutely-positioned dropdown anchored
 * to the avatar. */
.app-account {
  position: relative;
  flex-shrink: 0;
}
.app-account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  appearance: none;
  background: transparent;
  border: none;
  padding: 3px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.app-account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-brand-yellow);
  color: var(--color-brand-navy);
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  text-transform: uppercase;
}
.app-account-chevron {
  display: inline-flex;
  color: var(--color-text-dim);
  transition: transform 0.15s ease;
}
.app-account-trigger:hover .app-account-chevron {
  color: var(--color-text);
}
.app-account-trigger[aria-expanded="true"] .app-account-chevron {
  transform: rotate(180deg);
}
.app-account-trigger:focus-visible {
  outline: 2px solid var(--color-brand-yellow);
  outline-offset: 2px;
}

.app-account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  max-width: 300px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.app-account-dropdown[hidden] {
  display: none;
}
.app-account-email {
  font-size: 12px;
  color: var(--color-text-dim);
  padding: 8px 10px 6px;
  /* long emails wrap rather than overflow the menu */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.app-account-divider {
  height: 1px;
  background: var(--color-border);
  margin: 2px 0;
}
.app-account-logout-form { margin: 0; }
.app-account-logout {
  appearance: none;
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-danger, rgb(239, 68, 68));
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
}
.app-account-logout:hover {
  background: rgba(239, 68, 68, 0.12);
}
.app-account-logout:focus-visible {
  outline: 2px solid var(--color-danger, rgb(239, 68, 68));
  outline-offset: -2px;
}

/* Collapsed: hide the section label + project text. Keep a small
 * yellow-dot indicator when a project is active so users see that
 * SOME project is active even without expanding. */
.app-shell[data-sidebar-collapsed="true"] .sidebar-section-label,
.app-shell[data-sidebar-collapsed="true"] .sidebar-project-name,
.app-shell[data-sidebar-collapsed="true"] .sidebar-project-domain,
.app-shell[data-sidebar-collapsed="true"] .sidebar-project-switch,
.app-shell[data-sidebar-collapsed="true"] .sidebar-project-cta,
/* Hide the project mark too when the sidebar collapses — the collapsed
 * pill becomes a tiny yellow dot (rule below); the tile would visually
 * conflict with the dot treatment. */
.app-shell[data-sidebar-collapsed="true"] .sidebar-project-current .project-favicon {
  opacity: 0;
  pointer-events: none;
}

.app-shell[data-sidebar-collapsed="true"] .sidebar-project-current {
  padding: 0;
  border: none;
  background: transparent;
  height: 8px;
  border-radius: 50%;
  width: 8px;
  margin: 0 auto;
  background-color: var(--color-brand-yellow);
}

/* Collapsed: the gradient left-bar would conflict with the dot. */
.app-shell[data-sidebar-collapsed="true"] .sidebar-project-current::before {
  display: none;
}

/* ---- Monitoring placeholder ----------------------------------- */

.coming-soon-wrap {
  min-height: calc(100vh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.coming-soon-card {
  max-width: 560px;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 40px 36px;
  text-align: center;
}

.coming-soon-eyebrow {
  display: inline-block;
  background: var(--color-brand-yellow-soft);
  color: var(--color-brand-yellow);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.coming-soon-card h1 {
  font-size: 28px;
  font-weight: 900;
  margin: 0 0 16px;
  color: var(--color-text);
}

.coming-soon-card p {
  color: var(--color-text-dim);
  line-height: 1.6;
  margin: 0 0 14px;
  font-size: 15px;
}

.coming-soon-card p:last-child {
  margin-bottom: 0;
}

/* ---- Projects pages (Step 35) -------------------------------- */

.projects-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 32px 64px;
}

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.projects-header .page-heading {
  margin: 0;
}

.projects-new-link {
  white-space: nowrap;
}

.projects-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.projects-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.projects-item.is-active {
  border-color: var(--color-brand-yellow);
}

.projects-item-main {
  min-width: 0;
  flex: 1;
}

.projects-item-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.projects-active-badge {
  display: inline-block;
  background: var(--color-brand-yellow-soft);
  color: var(--color-brand-yellow);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.projects-item-meta {
  font-size: 12px;
  color: var(--color-text-dim);
  display: flex;
  gap: 12px;
  margin-top: 2px;
}

.projects-item-domain {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.projects-item-locale {
  letter-spacing: 0.04em;
  font-weight: 700;
}

.projects-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.projects-inline-form {
  display: inline;
  margin: 0;
}

.projects-empty {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  padding: 40px 24px;
  text-align: center;
}

.projects-empty p {
  margin: 0 0 8px;
  color: var(--color-text-dim);
}

.projects-empty p:first-child {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
}

.projects-empty .btn-primary {
  margin-top: 16px;
  display: inline-block;
}

.projects-form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 24px;
}

.projects-form-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

.projects-form-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 700;
}

/* Step 38: project favicon. Rendered inline-left of the project name
 * in every surface that displays a Project entity (sidebar pill,
 * projects list rows, edit page heading, audit "Auditing:" banner).
 * Sourced from Google's free favicon service (s2/favicons?domain=...)
 * via direct <img src> — no caching, no proxying. The `loading="lazy"`
 * and `onerror` hide-on-fail on the <img> tags themselves keep the
 * page layout intact when a domain has no favicon or Google returns
 * an error.
 *
 * vertical-align: middle handles inline contexts (the h1 baseline).
 * flex-shrink: 0 handles flex contexts (sidebar pill, list rows) so
 * the favicon doesn't get squeezed when the surrounding text is long.
 * object-fit: contain defends against non-square favicons (Google
 * occasionally returns 16x16 instead of 32x32). */
.project-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: contain;
  vertical-align: middle;
}

/* Macro variants (see _project_mark.html). --logo = an uploaded
 * (transparent) brand image; --initial = a gradient tile with the
 * project's first letter. Both share the .project-favicon box (and any
 * scoped size override above/below), so sizing stays per-surface. */
.project-favicon--logo {
  background: transparent;
}
.project-favicon--initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #d4459a, #F8C630);
  color: #ffffff;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  line-height: 1;
  /* font-size scales per box via the size overrides below; this default
   * suits the 20px base box. */
  font-size: 11px;
  text-transform: none;
}
/* Letter size for the larger tiles (sidebar 40, library badge 42). */
.sidebar-project-current .project-favicon--initial { font-size: 19px; }
.cw-library-project-context .project-favicon--initial { font-size: 20px; }

/* ---- Edit-page brand-logo section ------------------------------ */
.projects-logo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0 8px;
}
.projects-logo-preview .project-favicon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}
.projects-logo-preview .project-favicon--initial {
  font-size: 22px;
}
.projects-logo-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.projects-logo-form {
  display: flex;
  align-items: center;
  gap: 10px;
}
.projects-logo-form input[type="file"] {
  font-size: 12px;
  color: var(--color-text-dim);
  max-width: 240px;
}
.projects-logo-remove {
  color: var(--color-danger, rgb(239, 68, 68));
}

/* Step 38: edit-page heading restructured to "[favicon] Edit {name}".
 * page-heading is normally a plain block h1; we override to flex so
 * the favicon and text align on the same baseline. */
.projects-edit-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Step 37: section headings + optional badge for the new fallback
 * project form (and the edit form, which now carries all six
 * fields). The global modal uses its own classes (`pm-*`) in
 * modal.css. */
.projects-section-heading {
  margin: 28px 0 4px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.projects-section-heading:first-child {
  margin-top: 0;
}

.projects-section-hint {
  margin: 0 0 16px;
  color: var(--color-text-dim);
  font-size: 12px;
}

.projects-optional {
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-text-dim);
  opacity: 0.7;
  font-size: 11px;
  margin-left: 4px;
}

.projects-field {
  margin-bottom: 18px;
}

.projects-field textarea {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  box-sizing: border-box;
  resize: vertical;
}

.projects-field textarea:focus {
  outline: none;
  border-color: var(--color-brand-yellow);
  box-shadow: 0 0 0 3px var(--color-brand-yellow-soft);
}

.projects-field code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Step 38: edit-page Re-analyze button + status (same visual
 * vocabulary as the modal's analyze-zone, just placed inline in the
 * field row). */
.projects-field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.projects-field-label-row label {
  margin-bottom: 0;
}

.projects-reanalyze-btn {
  flex-shrink: 0;
}

.projects-reanalyze-status {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
}

.projects-reanalyze-status[hidden] {
  display: none;
}

.projects-reanalyze-status.is-loading {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-dim);
}

.projects-reanalyze-status.is-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.projects-reanalyze-status.is-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.projects-field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--color-text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.projects-field input[type="text"],
.projects-field select {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--color-text);
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

.projects-field input[type="text"]:focus,
.projects-field select:focus {
  outline: none;
  border-color: var(--color-brand-yellow);
  box-shadow: 0 0 0 3px var(--color-brand-yellow-soft);
}

.projects-field input[type="text"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.projects-field-hint {
  font-size: 12px;
  color: var(--color-text-dim);
  margin: 6px 0 0;
}

.projects-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

.projects-danger-zone {
  margin-top: 32px;
  background: var(--color-surface);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  padding: 20px 24px;
}

.projects-danger-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 800;
  color: #fca5a5;
}

.projects-danger-desc {
  font-size: 13px;
  color: var(--color-text-dim);
  margin: 0 0 14px;
  line-height: 1.5;
}

/* ---- Shared buttons used by projects pages (Step 35) ---------- */

.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-block;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn-primary {
  background: var(--color-brand-yellow);
  color: var(--color-brand-navy);
}

.btn-primary:hover {
  background: var(--color-brand-yellow-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--color-text-dim);
}

.btn-danger {
  background: transparent;
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

/* ---- Mobile collapse ------------------------------------------ */

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    flex-direction: row;
    padding: 8px 12px;
    align-items: center;
  }
  .sidebar-logo {
    margin: 0 12px 0 0;
    height: 32px;
  }
  .sidebar-logo-wordmark {
    display: none;
  }
  .sidebar-logo-mark {
    position: static;
    transform: none;
    opacity: 1;
  }
  .sidebar-tools {
    flex-direction: row;
    gap: 2px;
    flex: 1;
  }
  .sidebar-tool-label,
  .sidebar-tool-badge {
    display: none;
  }
  .sidebar-spacer,
  .sidebar-toggle {
    display: none;
  }
}

/* ── Stage 39: Geopatra-G loader ────────────────────────────────
 *
 * Two-phase brand-reveal animation shown during the wait while
 * monitoring suggestion generation runs server-side:
 *
 *   Phase 1 (~2.5s): the SVG g-mark is visible. The bowl is a static
 *   yellow ring; the descender (smile below the g) rotates around the
 *   bowl center, sweeping rightward — visually toward where the "o"
 *   of "geopatra.ai" sits in the full wordmark.
 *
 *   Phase 2 (~0.5s, triggered by .is-complete class from JS): the
 *   g-mark fades + scales out; the full Geopatra wordmark fades +
 *   scales in. After Phase 2 the wordmark holds while the browser
 *   waits for the server response.
 *
 * The CSS animation for the descender rotation is paused when the
 * loader hits .is-complete so the wordmark reveal isn't fighting
 * a still-spinning descender mid-fade.
 *
 * Geometry note: descender path is a quadratic curve centred on
 * (50, 50) so `transform-origin: 50px 50px` makes it pivot around
 * the bowl's center.
 *
 * Status text below cycles through 4 messages via the setTimeout
 * chain in main.html — independent of the visual phase.
 */

.geopatra-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 64px 24px;
  min-height: 240px;
}

.geopatra-loader[hidden] {
  display: none;
}

.geopatra-stage {
  position: relative;
  width: 320px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

/* Phase 1: the animated g-mark.
 *
 * width / height are sized against the 160-unit viewBox so the bowl
 * renders at roughly the same visual size as it did under the
 * original 100-unit viewBox (the bowl's r=38 was 30 px in the old
 * layout; 38/160 * 128 ≈ 30 px here). overflow: visible defends
 * against any further descender excursions beyond the viewBox if
 * the geometry is tweaked later. */
.geopatra-mark {
  width: 128px;
  height: 128px;
  color: var(--color-brand-yellow);
  overflow: visible;
  opacity: 1;
  transform: scale(1);
  transition:
    opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.g-descender {
  transform-origin: 50px 50px;
  animation: geopatra-descender-spin 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes geopatra-descender-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Phase 2: the full wordmark, hidden until JS adds .is-complete to
 * the parent loader. Position absolute so it overlays the same spot
 * as the g-mark within the stage. */
.geopatra-wordmark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 280px;
  height: auto;
  margin: 0;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
    transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}

/* Transition trigger: JS adds .is-complete after the rotation cycle
 * finishes, then waits for the transition before firing the actual
 * page navigation. */
.geopatra-loader.is-complete .geopatra-mark {
  opacity: 0;
  transform: scale(0.85);
}

.geopatra-loader.is-complete .g-descender {
  animation-play-state: paused;
}

.geopatra-loader.is-complete .geopatra-wordmark {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.loader-status-text {
  color: var(--color-text-dim);
  font-size: 14px;
  text-align: center;
  min-height: 1.5em;
  max-width: 320px;
  transition: opacity 0.3s ease;
}

/* Small inline spinner used by the empty-state "Set up monitoring →"
 * button click feedback. Reuses the descender-spin keyframes at a
 * smaller size with currentColor so it adapts to button context. */
.btn-inline-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: geopatra-descender-spin 0.7s linear infinite;
  vertical-align: -1px;
  margin-right: 6px;
}
