/* Device Operations app (/app) — app-specific layout on top of the shared
 * content-first frame (strata-web components/app_frame.html + showcase.css).
 *
 * Plain CSS on purpose: Tailwind only emits utilities it finds in templates
 * when `just css` regenerates the shared output.css, so bespoke layout lives
 * here, served from strata-ui/static like fragment-forms.js. Semantic theme
 * tokens only (var(--color-base-*), --color-primary, …), so every DaisyUI
 * theme — the dark zinc default, a product theme — renders it correctly. */

/* ── Header ─────────────────────────────────────────────────────────────── */
/* Brand, four tabs, Install, Console and the account do not fit one row on a
 * tablet (768–900px, where the frame's desktop nav appears): wrap rather than
 * push the page sideways. */
.strata-showcase-header { flex-wrap: wrap; row-gap: .25rem; }
.strata-showcase-nav { flex-wrap: wrap; }
.strata-showcase-brand .do-scope {
  display: block;
  margin-top: .1rem;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
  color: color-mix(in srgb, var(--color-base-content) 70%, var(--color-base-200));
}

/* On a product host the header carries the product's lockup over a mono
 * "Device Operations" plate (`templates/app/_layout.html`, host_brand). The
 * lockup's ink is currentColor, so it follows the theme. */
.strata-showcase-brand .do-brand { display: inline-flex; flex-direction: column; align-items: flex-start; gap: .3rem; }
.strata-showcase-brand .do-brand-mark { height: 1.6rem; }
.strata-showcase-brand .do-brand-plate {
  font-weight: 500;
  color: color-mix(in srgb, var(--color-base-content) 62%, var(--color-base-200));
}

/* ── Page head ──────────────────────────────────────────────────────────── */
.do-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: .5rem 1rem;
  margin-bottom: 1rem;
}
.strata-showcase h1.do-title {
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  font-weight: 700;
}
.do-sub {
  margin-top: .25rem;
  max-width: 70ch;
  font-size: .875rem;
  color: color-mix(in srgb, var(--color-base-content) 72%, var(--color-base-200));
}
.do-status {
  font-size: .75rem;
  white-space: nowrap;
  color: color-mix(in srgb, var(--color-base-content) 62%, var(--color-base-200));
}
.do-status::before {
  content: "";
  display: inline-block;
  width: .5rem;
  height: .5rem;
  margin-right: .4rem;
  border-radius: 999px;
  background: var(--color-success);
  vertical-align: middle;
}
.do-status.htmx-request::before { background: var(--color-primary); }
.do-status-error { color: var(--color-error); white-space: normal; }
.do-status-error::before { background: var(--color-error); }

/* ── The feed ───────────────────────────────────────────────────────────── */
/* One column at every width, like the Telegram topic it mirrors. A
 * multi-column grid moves every card one cell sideways (and wraps the last
 * of each row down) whenever the poll prepends a new alert, and the scroll
 * anchor in device-ops.js corrects only the vertical offset — the card being
 * read would jump columns. In one column an arrival only pushes the list
 * down, which the anchor undoes exactly. */
.do-feed {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  max-width: 48rem;
}
.do-single { max-width: 56rem; }
.do-narrow { max-width: 48rem; }
.do-empty, .do-more, .do-gap, .do-wide { grid-column: 1 / -1; }
.do-empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: .9rem;
  color: color-mix(in srgb, var(--color-base-content) 70%, var(--color-base-200));
}
/* The empty-state line sits inside the list; the first alert the poll
 * prepends hides it. */
.do-feed > .do-card ~ .do-empty { display: none; }
.do-more { display: flex; justify-content: center; padding: .5rem 0 1rem; }
.do-end { font-size: .8rem; color: color-mix(in srgb, var(--color-base-content) 55%, var(--color-base-200)); }
.do-gap {
  padding: .6rem .9rem;
  border-radius: .75rem;
  font-size: .85rem;
  background: color-mix(in srgb, var(--color-warning) 14%, var(--color-base-100));
}

/* ── A card ─────────────────────────────────────────────────────────────── */
.do-card, .do-tile, .do-panel {
  min-width: 0;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--color-base-100);
  border: 1px solid color-mix(in srgb, var(--color-base-content) 10%, transparent);
}
.do-panel { padding: 1rem; overflow: visible; }
.do-panel-title { font-size: 1rem; font-weight: 650; }
.do-card-body, .do-tile-body { display: grid; gap: .45rem; padding: .85rem .95rem 1rem; }
.do-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; }
.do-card-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
  font-weight: 650;
  text-transform: capitalize;
}
.do-card-where { font-size: .9rem; overflow-wrap: anywhere; }
.do-meta { font-size: .78rem; color: color-mix(in srgb, var(--color-base-content) 64%, var(--color-base-200)); }
.do-org {
  justify-self: start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}
.do-message { font-size: .875rem; overflow-wrap: anywhere; }
.do-msg:empty { display: none; }
.do-actions, .do-labels { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.do-labels { padding-top: .45rem; border-top: 1px dashed color-mix(in srgb, var(--color-base-content) 12%, transparent); }
.do-labels-title { width: 100%; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: color-mix(in srgb, var(--color-base-content) 58%, var(--color-base-200)); }
/* Tap targets: 44px (the frame's 48px is sized for a single primary button). */
.strata-showcase .do-card .btn, .strata-showcase .do-more .btn { min-height: 44px; }

/* Just arrived through the poll. */
.do-fresh { animation: do-arrive 2.4s ease-out 1; }
@keyframes do-arrive {
  0%   { box-shadow: 0 0 0 3px var(--color-primary); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ── The photo ──────────────────────────────────────────────────────────── */
.do-photo {
  position: relative;
  margin: 0;
  aspect-ratio: 16 / 9;
  background: var(--color-base-300);
  overflow: hidden;
}
.do-card-page .do-photo { aspect-ratio: auto; min-height: 12rem; }
.do-photo > a { display: block; width: 100%; height: 100%; }
.do-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.do-card-page .do-photo img { height: auto; max-height: 75dvh; object-fit: contain; background: #000; }
.do-photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  width: 100%;
  height: 100%;
  min-height: inherit;
  padding: 1rem;
  text-align: center;
  font-size: .9rem;
  color: color-mix(in srgb, var(--color-base-content) 78%, var(--color-base-200));
  background: linear-gradient(145deg, var(--color-base-300), var(--color-base-200));
}
.do-card-page .do-photo-empty { min-height: 12rem; }
/* A frame that did not load: the panel covers the <img>, which stays so
 * device-ops.js can retry it (and the panel goes when it loads). */
.do-photo-failed img { visibility: hidden; }
.do-photo-retry {
  position: absolute;
  inset: 0;
  height: auto;
}
.do-photo-chip {
  z-index: 1;
  position: absolute;
  top: .5rem;
  left: .5rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, .62);
  pointer-events: none;
}

/* ── Real-time grid ─────────────────────────────────────────────────────── */
.do-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
}

/* ── Real-time camera tiles ─────────────────────────────────────────────── */
/* The tiles are the shared camera status card (strata-web
 * components/status_board.html + camera_status_card.html, the camera boards'
 * markup) with camera-views.css for the Regular | Thermal switch. Only the
 * page's own furniture lives here. */
.do-live-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  margin-bottom: 1rem;
}
/* The status board's group heading is a small uppercase label
 * (`text-xs font-semibold uppercase tracking-wider`), as on the boards; the
 * frame's `.strata-showcase h2` display size would otherwise win. */
.strata-showcase .do-live h2 {
  font-size: .75rem;
  line-height: 1rem;
  letter-spacing: .05em;
  font-weight: 600;
}
/* A single-view tile's picture: the "trying again" panel (device-ops.js)
 * covers it, so it must be the panel's containing block. Two-view tiles'
 * faces are positioned already. */
.do-live .card .aspect-video { position: relative; }
.do-legend {
  display: grid;
  gap: .6rem 2rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid color-mix(in srgb, var(--color-base-content) 10%, transparent);
  font-size: .78rem;
  color: color-mix(in srgb, var(--color-base-content) 64%, var(--color-base-200));
}
@media (min-width: 640px) { .do-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .do-legend { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.do-legend > span { display: flex; align-items: flex-start; gap: .6rem; }
.do-legend .badge { flex: none; margin-top: .1rem; }
.do-legend-dot { flex: none; width: .6rem; height: .6rem; margin-top: .3rem; border-radius: 999px; }

/* ── Lightbox ───────────────────────────────────────────────────────────── */
.do-lightbox-box { width: min(96vw, 1400px); max-width: none; padding: .75rem; }
.do-lightbox-box img { display: block; width: 100%; max-height: 80dvh; object-fit: contain; border-radius: .5rem; background: #000; }
.do-lightbox-box p { margin-top: .5rem; }

@media (max-width: 767px) {
  /* Phone width goes to the frames, not the gutters. The bottom tab bar is
   * sticky (in flow), so the last card never ends up under it. */
  .strata-showcase-content { padding: 1rem .75rem 2rem; }
  /* Four tabs on a 360px phone: size each to its label so "Notifications"
   * fits whole instead of breaking mid-word as the frame's equal-width,
   * `overflow-wrap: anywhere` tabs would. */
  .strata-showcase .strata-showcase-bottom { flex-wrap: nowrap; gap: .15rem; }
  .strata-showcase .strata-showcase-bottom a {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow-wrap: normal;
    padding-inline: .3rem;
    font-size: .75rem;
  }
  /* One header row on a phone: the account name is in the console, not
   * needed here; the brand steps down a size. */
  .strata-showcase-header { flex-wrap: nowrap; padding-inline: 1rem; }
  .strata-showcase-header .strata-showcase-muted { display: none; }
  .strata-showcase .strata-showcase-brand { font-size: 1.1rem; min-width: 0; }
  .strata-showcase-header .btn { padding-inline: .5rem; }
  .do-feed, .do-grid { gap: .75rem; }
}

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