/* ============================================================
   Vodegero — Layout, app chrome, and utilities.
   Replaces the Bootstrap grid/utility layer. Everything is
   token-driven; no hard-coded colours.
   ============================================================ */

/* ------------------------------------------------------------
   Containers — centered max-widths per the DS layout rules
   (1240px app, 1140px detail, 24px gutters)
   ------------------------------------------------------------ */
.vg-container {
  width: 100%;
  max-width: var(--container-app, 1240px);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.vg-container--detail { max-width: 1140px; }
.vg-container--narrow { max-width: 760px; }
.vg-container--wide { max-width: var(--container-wide); }

:root { --container-app: 1240px; }

/* ------------------------------------------------------------
   Grid
   ------------------------------------------------------------ */
.vg-grid { display: grid; gap: var(--space-6); }
.vg-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.vg-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.vg-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Auto-fitting card grids — the workhorse for listings/stats */
.vg-grid--listings { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.vg-grid--stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.vg-grid--specs { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.vg-grid--gap-sm { gap: var(--space-3); }
.vg-grid--gap-lg { gap: var(--space-7); }

/* Sidebar + content (browse, admin content areas) */
.vg-grid--sidebar { grid-template-columns: 280px minmax(0, 1fr); align-items: start; }
.vg-grid--rail { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

@media (max-width: 1024px) {
  .vg-grid--sidebar,
  .vg-grid--rail { grid-template-columns: minmax(0, 1fr); }
  .vg-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .vg-grid--2,
  .vg-grid--3,
  .vg-grid--4 { grid-template-columns: minmax(0, 1fr); }
  .vg-grid--listings { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------
   Flex / spacing utilities — a deliberately small set
   ------------------------------------------------------------ */
.vg-row { display: flex; align-items: center; gap: var(--space-3); }
.vg-row--between { justify-content: space-between; }
.vg-row--end { justify-content: flex-end; }
.vg-row--center { justify-content: center; }
.vg-row--top { align-items: flex-start; }
.vg-row--baseline { align-items: baseline; }
.vg-row--wrap { flex-wrap: wrap; }

.vg-stack { display: flex; flex-direction: column; gap: var(--gap-stack); }
.vg-stack--sm { gap: var(--space-2); }
.vg-stack--lg { gap: var(--space-7); }

.vg-spacer { flex: 1 1 auto; }
.vg-hidden { display: none !important; }
.vg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.vg-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

@media (max-width: 900px) { .vg-hide-md { display: none !important; } }
@media (max-width: 640px) { .vg-hide-sm { display: none !important; } }
@media (min-width: 901px) { .vg-show-md { display: none !important; } }

/* ------------------------------------------------------------
   Typography helpers
   ------------------------------------------------------------ */
.vg-display {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  letter-spacing: var(--tracking-tighter);
  line-height: var(--leading-tight);
  color: var(--text-heading);
}
.vg-h1 { font-family: var(--font-display); font-weight: var(--fw-extra); font-size: var(--text-4xl); letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); color: var(--text-heading); }
.vg-h2 { font-family: var(--font-display); font-weight: var(--fw-extra); font-size: var(--text-3xl); letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); color: var(--text-heading); }
.vg-h3 { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--text-2xl); letter-spacing: var(--tracking-tight); color: var(--text-heading); }
.vg-h4 { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--text-xl); color: var(--text-heading); }

.vg-lede { font-size: var(--text-lg); line-height: var(--leading-normal); color: var(--text-secondary); max-width: 62ch; }
.vg-muted { color: var(--text-muted); }
.vg-secondary { color: var(--text-secondary); }
.vg-small { font-size: var(--text-sm); }
.vg-xs { font-size: var(--text-xs); }
.vg-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.vg-num { font-variant-numeric: tabular-nums; }

/* Mono uppercase eyebrow — the DS's one sanctioned ALL-CAPS style */
.vg-eyebrow {
  font-family: var(--eyebrow-font);
  font-size: var(--text-3xs);
  letter-spacing: var(--eyebrow-track);
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}
.vg-eyebrow--brand { color: var(--brand-primary); }

/* ------------------------------------------------------------
   Page scaffolding
   ------------------------------------------------------------ */
.vg-page { padding-block: var(--space-9) var(--space-11); }
.vg-page--tight { padding-block: var(--space-7) var(--space-9); }

.vg-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-7);
  flex-wrap: wrap;
}
.vg-page-head__text { display: flex; flex-direction: column; gap: var(--space-2); }
.vg-page-head__title {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  font-size: var(--text-3xl);
  letter-spacing: var(--tracking-tight);
  color: var(--text-heading);
}
.vg-page-head__sub { font-size: var(--text-md); color: var(--text-secondary); }

.vg-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--text-muted); flex-wrap: wrap; }
.vg-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.vg-breadcrumb a:hover { color: var(--brand-primary); text-decoration: none; }
.vg-breadcrumb__sep { color: var(--ink-300); display: inline-flex; }

.vg-section { margin-block: var(--space-9); }
.vg-divider { height: 1px; background: var(--border-cool); border: none; margin-block: var(--space-6); }
.vg-divider--warm { background: var(--border-warm); }

/* ------------------------------------------------------------
   Top navigation — ports ui_kits/webapp/Shell.jsx TopNav
   ------------------------------------------------------------ */
.vg-topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 248, 242, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-warm);
}
.vg-topnav__inner {
  max-width: var(--container-app);
  margin-inline: auto;
  padding-inline: var(--gutter);
  height: 66px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.vg-topnav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  text-decoration: none;
}
.vg-topnav__brand:hover { text-decoration: none; }
.vg-topnav__brand img { height: 34px; width: auto; display: block; }
.vg-topnav__wordmark {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  font-size: 20px;
  letter-spacing: var(--tracking-snug);
  color: var(--brand-primary);
}

.vg-topnav__search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-card);
  border: 1px solid var(--border-cool);
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition-color);
}
.vg-topnav__search:focus-within { border-color: var(--border-focus); box-shadow: var(--ring); }
.vg-topnav__search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-body);
  min-width: 0;
}
.vg-topnav__search input::placeholder { color: var(--text-muted); }

.vg-topnav__links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.vg-topnav__link {
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: 14px;
  color: var(--text-secondary);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: var(--transition-color);
  white-space: nowrap;
}
.vg-topnav__link:hover { background: var(--sand-100); color: var(--text-heading); text-decoration: none; }
.vg-topnav__link.is-active { background: var(--sand-100); color: var(--text-heading); }

.vg-topnav__actions { display: flex; align-items: center; gap: 10px; flex: none; }
.vg-topnav__bell { position: relative; }
.vg-topnav__bell-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger-500);
  border: 2px solid var(--bg-page);
}
.vg-topnav__toggle { display: none; }

@media (max-width: 1024px) {
  .vg-topnav__search { max-width: none; }
}
@media (max-width: 900px) {
  .vg-topnav__inner { gap: 12px; }
  .vg-topnav__toggle { display: inline-flex; }
  .vg-topnav__links {
    display: none;
    position: absolute;
    top: 66px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-warm);
    padding: var(--space-3) var(--gutter);
    box-shadow: var(--shadow-md);
  }
  .vg-topnav__links.is-open { display: flex; }
  .vg-topnav__wordmark { display: none; }
}

/* ------------------------------------------------------------
   Nav progress bar (htmx page transitions)
   ------------------------------------------------------------ */
.vg-nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--brand-accent);
  z-index: 2000;
  opacity: 0;
  transition: width var(--dur-slow) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
.vg-nav-progress.is-active { opacity: 1; }

/* ------------------------------------------------------------
   Public footer
   ------------------------------------------------------------ */
.vg-footer {
  border-top: 1px solid var(--border-warm);
  background: var(--bg-page-alt);
  margin-top: auto;
}
.vg-footer__inner {
  max-width: var(--container-app);
  margin-inline: auto;
  padding: var(--space-10) var(--gutter) var(--space-7);
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: var(--space-8);
}
@media (max-width: 900px) {
  .vg-footer__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-7); }
}
@media (max-width: 560px) {
  .vg-footer__inner { grid-template-columns: minmax(0, 1fr); }
}
.vg-footer__brand { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }

/* Shield + wordmark lockup, mirroring .vg-topnav__brand. */
.vg-footer__lockup { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.vg-footer__lockup:hover { text-decoration: none; }
/* The mark is a portrait shield (930x1145). `align-self` is load-bearing: the
   parent is a column flex container, so its cross axis is the width and the
   default `stretch` would widen the logo to the whole column, beating
   `width: auto`. */
.vg-footer__lockup img {
  height: 40px;
  width: auto;
  align-self: center;
  flex: none;
  display: block;
}
.vg-footer__wordmark {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-snug);
  color: var(--brand-primary);
}
.vg-footer__blurb { font-size: var(--text-sm); color: var(--text-secondary); max-width: 34ch; }
.vg-footer__col { display: flex; flex-direction: column; gap: var(--space-3); }
.vg-footer__title {
  font-family: var(--font-body);
  font-weight: var(--fw-bold);
  font-size: var(--text-sm);
  color: var(--text-heading);
}
.vg-footer__link {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition-color);
}
.vg-footer__link:hover { color: var(--brand-primary); text-decoration: none; }
.vg-footer__bar {
  max-width: var(--container-app);
  margin-inline: auto;
  padding: var(--space-5) var(--gutter);
  border-top: 1px solid var(--border-warm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Body shell so the footer sinks to the bottom on short pages */
.vg-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.vg-body > main { flex: 1 0 auto; }

/* ------------------------------------------------------------
   Admin shell
   ------------------------------------------------------------ */
.vg-admin {
  --vg-side-w: 256px;
  --vg-topbar-h: 64px;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--vg-side-w) minmax(0, 1fr);
  grid-template-rows: var(--vg-topbar-h) minmax(0, 1fr);
  grid-template-areas:
    "side topbar"
    "side main";
  background: var(--bg-page);
}

.vg-admin__side {
  grid-area: side;
  background: var(--ink-900);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.vg-admin__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--space-5);
  height: var(--vg-topbar-h);
  flex: none;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.vg-admin__brand:hover { text-decoration: none; }
/* The blue shield disappears on dark/blue fields — the DS mandates a white chip. */
.vg-admin__brand-chip {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 4px;
  display: inline-flex;
  flex: none;
}
.vg-admin__brand-chip img { height: 24px; width: auto; display: block; }
.vg-admin__brand-text {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  font-size: var(--text-lg);
  color: #fff;
  letter-spacing: var(--tracking-snug);
}

.vg-admin__nav { padding: var(--space-4) var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.vg-admin__nav-group { margin-top: var(--space-5); }
.vg-admin__nav-group:first-child { margin-top: 0; }
.vg-admin__nav-title {
  font-family: var(--eyebrow-font);
  font-size: var(--text-3xs);
  letter-spacing: var(--eyebrow-track);
  text-transform: uppercase;
  color: rgba(229, 231, 235, 0.45);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}
.vg-admin__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  color: rgba(229, 231, 235, 0.7);
  text-decoration: none;
  transition: var(--transition-color);
}
.vg-admin__link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.vg-admin__link.is-active { background: rgba(255, 255, 255, 0.08); color: #fff; font-weight: var(--fw-semibold); }
.vg-admin__link.is-active .vg-icon { color: var(--gold-400); }
.vg-admin__link .vg-icon { color: rgba(229, 231, 235, 0.45); flex: none; }
.vg-admin__link:hover .vg-icon { color: #fff; }

.vg-admin__side-foot {
  margin-top: auto;
  padding: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.vg-admin__side-user { display: flex; flex-direction: column; min-width: 0; }
.vg-admin__side-name { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: #fff; }
.vg-admin__side-role { font-size: var(--text-xs); color: rgba(229, 231, 235, 0.45); }

.vg-admin__topbar {
  grid-area: topbar;
  background: rgba(251, 248, 242, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-warm);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-inline: var(--space-6);
  position: sticky;
  top: 0;
  z-index: 40;
}
.vg-admin__burger { display: none; }
.vg-admin__main { grid-area: main; padding: var(--space-7) var(--space-6) var(--space-11); min-width: 0; }

.vg-admin__scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(21, 26, 36, 0.45);
  backdrop-filter: blur(3px);
  z-index: 59;
}

@media (max-width: 1024px) {
  .vg-admin {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "main";
  }
  .vg-admin__side {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--vg-side-w);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-out);
  }
  .vg-admin__side.is-open { transform: translateX(0); }
  .vg-admin__scrim.is-open { display: block; }
  .vg-admin__burger { display: inline-flex; }
  .vg-admin__main { padding-inline: var(--space-4); }
}

/* ------------------------------------------------------------
   Auth shell
   ------------------------------------------------------------ */
.vg-auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.vg-auth__form-pane {
  display: flex;
  flex-direction: column;
  padding: var(--space-8) var(--space-9);
  background: var(--bg-page);
}
.vg-auth__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 400px;
  width: 100%;
  margin-inline: auto;
}
.vg-auth__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.vg-auth__brand:hover { text-decoration: none; }
.vg-auth__brand img { height: 34px; width: auto; }
.vg-auth__brand-text {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  font-size: 20px;
  color: var(--brand-primary);
  letter-spacing: var(--tracking-snug);
}
.vg-auth__title {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  font-size: var(--text-4xl);
  letter-spacing: var(--tracking-tight);
  color: var(--text-heading);
  line-height: var(--leading-tight);
}
.vg-auth__sub { font-size: var(--text-md); color: var(--text-secondary); margin-top: var(--space-2); }
.vg-auth__foot {
  flex: none;
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.vg-auth__foot a { color: var(--text-muted); text-decoration: none; }
.vg-auth__foot a:hover { color: var(--brand-primary); }

/* Brand panel — blueprint grid motif, per the DS login panel */
.vg-auth__art {
  position: relative;
  background-color: var(--blue-800);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 44px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-11) var(--space-9);
  overflow: hidden;
  color: #fff;
}
.vg-auth__art::before {
  content: "";
  position: absolute;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(254, 210, 61, 0.22) 0%, rgba(254, 210, 61, 0) 62%);
  top: -180px;
  right: -180px;
  pointer-events: none;
}
.vg-auth__art::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(11, 107, 255, 0.32) 0%, rgba(11, 107, 255, 0) 62%);
  bottom: -160px;
  left: -160px;
  pointer-events: none;
}
.vg-auth__art-inner { position: relative; z-index: 1; max-width: 440px; }
.vg-auth__art-chip {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 8px;
  display: inline-flex;
  margin-bottom: var(--space-6);
}
.vg-auth__art-chip img { height: 40px; width: auto; display: block; }
.vg-auth__art-title {
  font-family: var(--font-display);
  font-weight: var(--fw-extra);
  font-size: var(--text-5xl);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: #fff;
}
.vg-auth__art-lede {
  font-size: var(--text-lg);
  color: rgba(255, 255, 255, 0.78);
  margin-top: var(--space-4);
  line-height: var(--leading-normal);
}
.vg-auth__features { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-9); }
.vg-auth__feature { display: flex; align-items: flex-start; gap: var(--space-3); }
.vg-auth__feature-icon {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--gold-400);
  display: flex;
  align-items: center;
  justify-content: center;
}
.vg-auth__feature-title { font-family: var(--font-body); font-weight: var(--fw-bold); font-size: var(--text-base); color: #fff; }
.vg-auth__feature-body { font-size: var(--text-sm); color: rgba(255, 255, 255, 0.65); }

@media (max-width: 900px) {
  .vg-auth { grid-template-columns: minmax(0, 1fr); }
  .vg-auth__art { display: none; }
  .vg-auth__form-pane { padding: var(--space-7) var(--space-5); }
}

/* ------------------------------------------------------------
   htmx helpers
   ------------------------------------------------------------ */
.htmx-indicator { opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }
.vg-swapping { opacity: 0.55; transition: opacity var(--dur-fast) var(--ease-out); }

/* Swap fade. Visible by default — JS only ever adds `.is-fading` for the
   fade-out, so a failed swap can never leave the page stuck invisible. */
.vg-page-transition { opacity: 1; transition: opacity var(--dur-fast) var(--ease-out); }
.vg-page-transition.is-fading { opacity: 0; }
