/* =====================================================================
   TUMRIX STUDIO v0.1 - STUDIO LAYER
   DESIGN PROTOTYPE ONLY. Not production code.

   Deliberately small. Everything this prototype needs already exists in
   the v0.4 theme, which is loaded first:

     ../shiftpocket-v0.4/theme/tokens.electric.css   every colour and size
     ../shiftpocket-v0.4/theme/base.css              resets, type
     ../shiftpocket-v0.4/theme/components.css        cards, buttons, chips
     ../shiftpocket-v0.4/theme/admin.css             rail, metrics, tables

   This file adds only what a multi-app studio needs and the single-app
   admin console did not: application cards, the breadcrumb, the app
   switcher, and the modal used by "Add application".

   RULE, inherited: no literal colour, radius or timing value.
   ===================================================================== */

/* ---- Rail brand ------------------------------------------------------
   `admin.css` styles these two but does not stack them, because its own
   markup put them in separate rows. Here they share a wrapper. */
.rail-name, .rail-sub { display: block; }

/* ---- Section headings ------------------------------------------------
   `components.css` has `.section-head` but no title/note inside it,
   because the mobile screens use an uppercase eyebrow there. A studio
   page wants a real heading, so these two are the only type rules here. */
.section-title { font-size: var(--fs-heading); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); }
.section-note { font-size: var(--fs-sub); color: var(--fg-muted); }

/* ---- Application cards ---------------------------------------------- */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(19rem, 100%), 1fr));
  gap: var(--sp-4);
}

.app-card {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  border: var(--hairline) solid var(--line);
  background: var(--surface);
  text-align: left; width: 100%; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.app-card:hover { border-color: var(--accent); }
.app-card:active { transform: scale(0.995); }
.app-card[aria-disabled="true"] { cursor: not-allowed; opacity: 0.6; }
.app-card[aria-disabled="true"]:hover { border-color: var(--line); }

.app-card-head { display: flex; align-items: center; gap: var(--sp-3); }
.app-mark {
  display: flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; flex: none;
  border-radius: var(--r-md);
  background: var(--accent-wash); color: var(--accent-ink);
}
.app-mark .icon { width: 1.25rem; height: 1.25rem; }
.app-name { font-size: var(--fs-heading); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); }
.app-slug { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--fg-muted); }
.app-desc { font-size: var(--fs-sub); color: var(--fg-2); line-height: var(--lh-body); }
.app-card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: auto; }

/* The immutable internal id, shown because it is what authorisation uses. */
.app-id { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--fg-muted); }

/* ---- "Add application" tile ----------------------------------------- */
.app-card.is-new {
  align-items: center; justify-content: center; text-align: center;
  gap: var(--sp-2);
  border-style: dashed;
  background: transparent;
  min-height: 11rem;
  color: var(--fg-2);
}
.app-card.is-new .app-mark { background: var(--surface-muted); color: var(--fg-2); }

/* ---- Breadcrumb ------------------------------------------------------ */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-sub); }
.crumbs a { color: var(--fg-muted); text-decoration: none; border-radius: var(--r-xs); }
.crumbs a:hover { color: var(--accent-ink); text-decoration: underline; }
.crumbs .sep { color: var(--fg-muted); }
.crumbs .here { color: var(--fg); font-weight: var(--fw-semibold); }

/* ---- App switcher ---------------------------------------------------- */
.switcher { position: relative; }
.switcher-btn {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  border: var(--hairline) solid var(--line);
  background: var(--surface);
  color: var(--fg); font-size: var(--fs-label); font-weight: var(--fw-semibold);
  cursor: pointer;
}
.switcher-btn:hover { border-color: var(--line-strong); }
.switcher-menu {
  position: absolute; z-index: 40; top: calc(100% + var(--sp-1)); left: 0;
  min-width: 15rem;
  padding: var(--sp-1);
  border-radius: var(--r-md);
  border: var(--hairline) solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  display: grid; gap: var(--sp-1);
}
.switcher-menu[hidden] { display: none; }
.switcher-item {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-3);
  border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--fg-2); font-size: var(--fs-body); text-align: left; width: 100%;
  cursor: pointer;
}
.switcher-item:hover { background: var(--surface-muted); }
.switcher-item[aria-current="true"] { background: var(--accent-wash); color: var(--accent-ink); font-weight: var(--fw-semibold); }

/* ---- Environment indicator ------------------------------------------ */
.env {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 0 var(--sp-2); min-height: 1.375rem;
  border-radius: var(--r-pill);
  font-size: var(--fs-micro); font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide); text-transform: uppercase;
}
.env-dev { background: var(--warn-wash); color: var(--warn-ink); }
.env-prod { background: var(--success-wash); color: var(--success-ink); }

/* ---- Modal ----------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  background: var(--scrim);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(28rem, 100%);
  max-height: calc(100vh - var(--sp-8));
  overflow-y: auto;
  padding: var(--sp-5);
  border-radius: var(--r-xl);
  border: var(--hairline) solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  display: grid; gap: var(--sp-4);
}
.modal h2 { font-size: var(--fs-title); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); }
.modal-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; }

/* ---- Two-column page layout ------------------------------------------ */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(min(20rem, 100%), 0.6fr); gap: var(--sp-4); align-items: start; }

/* ---- Anchor offset ---------------------------------------------------
   `.admin-top` is sticky, so an in-page link would otherwise scroll its
   target underneath the header. `scroll-margin-top` reserves the header's
   height plus a little breathing room. It is set generously because the
   header wraps to two lines on a narrow screen. */
[id] { scroll-margin-top: 7rem; }

/* ---- Technical details ------------------------------------------------
   Collapsed by default. Event codes and internal ids matter when
   something has gone wrong and are noise the rest of the time. */
.tech { margin-top: var(--sp-2); }
.tech > summary {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  min-height: var(--tap-min); padding: 0 var(--sp-1);
  border-radius: var(--r-xs);
  font-size: var(--fs-micro); font-weight: var(--fw-semibold);
  color: var(--fg-muted); cursor: pointer; list-style: none;
}
.tech > summary::-webkit-details-marker { display: none; }
.tech > summary::before { content: "\25B8"; display: inline-block; transition: transform var(--t-fast) var(--ease); }
.tech[open] > summary::before { transform: rotate(90deg); }
.tech > summary:hover { color: var(--fg-2); }
.tech > .kv { margin-top: var(--sp-2); padding-left: var(--sp-3); }
.tech code, .tech .app-id {
  font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--fg-2);
}
.tech .kv dd { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  .tech > summary::before { transition: none; }
}

/* `.cell-sub` is declared block only inside `.dtable`. In a definition
   list it would otherwise run straight on from the value it qualifies. */
.kv dd .cell-sub { display: block; margin-top: 0.125rem; }

/* ---- Copy feedback ---------------------------------------------------- */
.copy-btn { gap: var(--sp-1); }
.copy-btn.is-ok { border-color: var(--success); color: var(--success-ink); }
.copy-btn.is-bad { border-color: var(--warn); color: var(--warn-ink); }

/* ---- The one persistent demo indicator --------------------------------
   Replaces a banner on every section. It sits in the header, it is always
   visible, and it is the same object on every view. */
.demo-flag {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 0 var(--sp-2); min-height: 1.5rem;
  border-radius: var(--r-pill);
  border: var(--hairline) solid var(--warn);
  background: var(--warn-wash); color: var(--warn-ink);
  font-size: var(--fs-micro); font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide); text-transform: uppercase;
  white-space: nowrap;
}
.demo-flag .icon { width: 0.8125rem; height: 0.8125rem; }

/* A metric whose value is invented rather than measured. */
.metric-sample .metric-value { color: var(--fg-2); }
.metric-sample .metric-key::after {
  content: "Sample";
  margin-left: var(--sp-2);
  padding: 0 var(--sp-1);
  border-radius: var(--r-xs);
  background: var(--warn-wash); color: var(--warn-ink);
  letter-spacing: 0;
}
.metric-none .metric-value { color: var(--fg-muted); font-weight: var(--fw-semibold); font-size: var(--fs-title); }

/* ---- Narrow screens --------------------------------------------------
   The rail becomes a horizontal strip above the content. A studio
   dashboard is a desktop tool, but a phone must still be able to read it
   rather than scroll sideways. */
@media (max-width: 60rem) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: static; height: auto; width: 100%;
    border-right: 0; border-bottom: var(--hairline) solid var(--line);
  }
  .rail-nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .rail-foot { margin-top: var(--sp-3); padding-top: var(--sp-3); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Reduced motion --------------------------------------------------
   The tokens file already collapses its duration variables under this
   query; this is belt and braces for the transitions declared above. */
@media (prefers-reduced-motion: reduce) {
  .app-card { transition: none; }
  .app-card:active { transform: none; }
}
