/* Daytime road signage: highway-sign green, white sign borders, concrete
   background. Keep --sign in sync with SIGN in app.py */
:root {
  --sign: #00734b;
  --sign-dark: #005f3e;
  --sign-soft: #e7f5ef;
  --concrete: #ecede7;
  --card: #ffffff;
  --line: #dcded6;
  --ink: #1f2a24;
  --muted: #6b746e;
  --caution: #ffd43b;
  --mono: "Overpass Mono", ui-monospace, monospace;
}

body {
  color: var(--ink);
  background-color: var(--concrete);
  /* Subtle aggregate texture */
  background-image: radial-gradient(rgba(31, 42, 36, 0.05) 1px, transparent 1px);
  background-size: 6px 6px;
}

/* Header: a green highway sign with an inset white border */

.mantine-AppShell-header {
  background: var(--sign);
  border-bottom: 0;
  box-shadow: inset 0 -4px 0 var(--caution);
  color: #fff;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 8px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.3;
}

.app-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-link {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 12px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
}

.header-link:hover {
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

.plotly-logo {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 6px;
  background: #fff;
  border-radius: 8px;
}

.plotly-logo img {
  height: 32px;
  width: auto;
}

/* Page: both feeds and the console fit in one viewport on desktop */

.page {
  box-sizing: border-box;
  height: calc(100dvh - var(--app-shell-header-height));
  max-width: 1800px;
  margin: 0 auto;
  padding: 16px 20px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
}

.feeds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-height: 0;
}

/* Camera feed card */

.feed {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(31, 42, 36, 0.06), 0 8px 24px -12px rgba(31, 42, 36, 0.18);
  overflow: hidden;
}

.feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.feed-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}

.feed-badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  color: #fff;
  background: var(--sign);
}

.feed-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.feed-subtitle {
  font-size: 14px;
  color: var(--muted);
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-meta {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--sign-dark);
  background: var(--sign-soft);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.feed-body {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 12px;
  border-radius: 10px;
  /* Asphalt grey behind the letterboxed frame */
  background: #2a2e2b;
  overflow: hidden;
}

/* Center the frame and size it to its 512:320 aspect ratio, whichever side of
   the panel is the limit */
.feed-loading {
  position: absolute !important;
  inset: 0;
  container-type: size;
  display: grid;
  place-items: center;
}

/* !important beats the inline height that responsive dcc.Graph sets */
.feed-graph {
  width: min(100cqw, 160cqh) !important;
  height: min(100cqh, 62.5cqw) !important;
}

.feed-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 46px;
  align-items: center;
  padding: 8px 12px 10px;
  font-size: 14px;
}

.count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: #f2f3ef;
  color: var(--ink);
  font-weight: 600;
}

.count b {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
}

.count-empty {
  color: var(--muted);
  padding-left: 4px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}

/* Console */

.console {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) auto minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 14px 20px 16px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(31, 42, 36, 0.06), 0 8px 24px -12px rgba(31, 42, 36, 0.18);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.control-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.control-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.control-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--sign);
}

.class-picker {
  background: #f2f3ef;
}

.frame-position {
  min-width: 112px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.frame-position b {
  color: var(--ink);
  font-weight: 600;
}

/* Narrower screens: drop the class names, then stack everything and scroll */

@media (max-width: 1400px) {
  .seg-label {
    display: none;
  }

  .console {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  .console {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 28px;
  }
}

@media (max-width: 800px) {
  .page {
    height: auto;
    display: flex;
    flex-direction: column;
    padding: 12px;
  }

  .feeds {
    grid-template-columns: minmax(0, 1fr);
  }

  .feed-body {
    flex: none;
    aspect-ratio: 512 / 320;
  }

  .console {
    grid-template-columns: minmax(0, 1fr);
  }

  .feed-subtitle,
  .eyebrow {
    display: none;
  }

  .app-title {
    font-size: 15px;
    white-space: normal;
  }

  .plotly-logo img {
    height: 22px;
  }

  .feed-head {
    flex-wrap: wrap;
    row-gap: 6px;
  }
}
