/* ==========================================================================
   Setup Sheet: the read-only sheet view (Figma: Session Setup, "Page").
   Stands alone so this folder can be published as it is. Token values are
   copied from the Figma variables; names follow hub/static/shared/hub.css.
   Design frame: 1728 x 1117.
   ========================================================================== */

:root {
  color-scheme: dark;

  --canvas: #2B3737;
  --bar: #263232;                      /* Figma: #757575 in soft light over the canvas */
  --line: rgba(217, 208, 199, 0.10);

  --ink-1: #D9D0C7;                    /* text/primary   */
  --ink-2: #BDB8B0;                    /* text/secondary */
  --ink-3: #ACA8A2;                    /* text/tertiary  */
  --ink-off: rgba(217, 208, 199, 0.40); /* text/disabled  */

  --surface: #323F3F;                  /* an instrument on the plan */
  --raised: #364444;                   /* the editor */
  --line-strong: rgba(217, 208, 199, 0.18);
  --ink-on-bone: #2B3737;
  --scrim: rgba(10, 16, 16, 0.58);
  --danger: #FF9189;

  --plan-line: #8E8E8E;                /* walls and tie line panels */
  --plan-label: rgba(255, 255, 255, 0.86);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Segoe UI", system-ui, sans-serif;
  --weight-light: 274;

  /* Size and line height are the Figma text styles (H4, H6, M, S / Light).
     Tracking is not: a browser already applies San Francisco's own tracking to
     the system font and Figma does not, so these are the differences that land
     the text on Figma's widths (Figma: -0.21, -0.09, -0.03, 0.08). */
  --h4-size: 19.2px;  --h4-leading: 24px;  --h4-tracking: 0.24px;
  --h6-size: 14.4px;  --h6-leading: 20px;  --h6-tracking: 0.12px;
  --m-size: 13px;     --m-leading: 19px;   --m-tracking: 0.05px;
  --s-size: 11.5px;   --s-leading: 16px;   --s-tracking: 0.05px;

  --row-height: 38px;
  --tap: 44px;         /* a finger's target */
  --input-size: 17px;  /* typed text: no zoom on focus on an iPhone */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink-1);
  font-family: var(--font);
  font-weight: var(--weight-light);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p {
  margin: 0;
  font-weight: inherit;
}

/* Session bar ------------------------------------------------------------- */

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 16px 24px;
  background: var(--bar);
}

.session-bar__id {
  display: flex;
  align-items: center;
  gap: 28px;
  min-width: 0;
}

.session-bar__name,
.session-bar__artist {
  font-size: var(--h4-size);
  line-height: var(--h4-leading);
  letter-spacing: var(--h4-tracking);
  white-space: nowrap;
}

.session-bar__artist {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-bar__date {
  flex: none;
  font-size: var(--h6-size);
  line-height: var(--h6-leading);
  letter-spacing: var(--h6-tracking);
  white-space: nowrap;
}

/* Layout: sheet on the left; session files and the floor plan on the right - */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 771fr) minmax(0, 873fr);
  padding: 28px 60px 0 24px;
}

.sheet {
  padding-bottom: 84px;
}

/* Said in place of the sheet: nothing published yet, no tracks, or no connection */
.sheet__note,
.sheet__hint {
  padding: 16px;
  color: var(--ink-3);
  font-size: var(--m-size);
  line-height: var(--m-leading);
  letter-spacing: var(--m-tracking);
}

.side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-left: 24px;
}

/* Session files: what Export built, to download ----------------------------- */

.files {
  width: min(100%, 480px);
  padding-bottom: 28px;
}

.files__list {
  margin: 0;
  padding: 0 16px;
  list-style: none;
}

.file {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--tap);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.file__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file__name,
.file__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file__name {
  font-size: var(--m-size);
  line-height: var(--m-leading);
  letter-spacing: var(--m-tracking);
}

.file__meta,
.file__get {
  font-size: var(--s-size);
  line-height: var(--s-leading);
  letter-spacing: var(--s-tracking);
}

.file__meta {
  color: var(--ink-3);
}

.file__get {
  flex: none;
  color: var(--ink-2);
}

.file:hover .file__get,
.file:focus-visible .file__get {
  color: var(--ink-1);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* The floor plan: drawn by sheet.js from the session's studio, with the instruments where the
   app's Layout page stands them. It fills the right column up to the mockup's size and sits in
   the bottom right corner, staying there as the sheet scrolls. */
.plan {
  margin-top: auto;
  position: sticky;
  bottom: 68px;
  margin-bottom: 68px;
  min-width: 0;
}

/* Exactly the plan's shape, whichever of the column, the mockup's size or the window limits it */
.plan__stage {
  position: relative;
  margin-left: auto;
  width: min(100%, var(--plan-max), calc((100vh - 152px) * var(--plan-ratio)));
  aspect-ratio: var(--plan-ratio);
}

.plan svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.plan__wall {
  fill: none;
  stroke: var(--plan-line);
  stroke-width: 2px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.plan__panel {
  stroke: var(--plan-line);
  stroke-width: 6px;
  vector-effect: non-scaling-stroke;
}

.plan__label {
  fill: var(--plan-label);
  font-size: var(--label-size, var(--s-size));
}

/* An instrument, centred where it stands */
.plan__place {
  position: absolute;
  transform: translate(-50%, -50%);
  max-width: 170px;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-1);
  font-size: var(--s-size);
  line-height: var(--s-leading);
  letter-spacing: var(--s-tracking);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Group ------------------------------------------------------------------- */

.group__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
}

.group__name {
  font-size: var(--m-size);
  line-height: var(--m-leading);
  letter-spacing: var(--m-tracking);
  white-space: nowrap;
}

.group__rule {
  flex: 1;
  height: 1px;
  background: var(--ink-off);
}

.group__body {
  padding: 0 16px;
}

/* Rows -------------------------------------------------------------------- */

.rows {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--s-size);
  line-height: var(--s-leading);
  letter-spacing: var(--s-tracking);
}

.rows th,
.rows td {
  height: var(--row-height);
  padding: 0;
  border-bottom: 1px solid var(--line);
  font-weight: inherit;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rows th {
  color: var(--ink-3);
}

/* The mockup's Channel (164) and Microphone (95) widths fit its placeholder words; real mic
   names need the room, and a channel is only a number. */
.rows__tie { width: 80px; }
.rows__channel { width: 110px; }
.rows__mic { width: 180px; }

/* A track can be tapped to change it */
.rows tbody tr {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rows tbody tr:hover td,
.rows tbody tr:active td {
  background: rgba(217, 208, 199, 0.045);
}

.rows tbody tr:focus-visible {
  outline: 1px solid var(--ink-2);
  outline-offset: -1px;
}

/* Changed on the page, not yet taken by the app: a ring at the row's end */
.rows tr.is-pending td:last-child {
  position: relative;
  padding-right: 16px;
}

.rows tr.is-pending td:last-child::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -4px;
  border: 1px solid var(--ink-2);
  border-radius: 50%;
}

/* The editor: one track's tie line, channel and microphone ------------------ */

.editor {
  width: min(420px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--raised);
  color: var(--ink-1);
  font-weight: 400;
}

.editor::backdrop {
  background: var(--scrim);
}

.editor__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.editor__title {
  font-size: var(--h4-size);
  line-height: var(--h4-leading);
  letter-spacing: var(--h4-tracking);
  font-weight: var(--weight-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor__title:focus {
  outline: none;
}

.editor__pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field__label {
  color: var(--ink-2);
  font-size: var(--m-size);
  line-height: var(--m-leading);
}

.field__input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--canvas);
  color: var(--ink-1);
  font: inherit;
  font-size: var(--input-size);
}

.field__input:focus-visible {
  outline: 2px solid var(--ink-2);
  outline-offset: 1px;
}

.field__input:disabled {
  opacity: 0.5;
}

.editor__error {
  min-height: var(--m-leading);
  color: var(--danger);
  font-size: var(--m-size);
  line-height: var(--m-leading);
}

.editor__error:empty {
  display: none;
}

.editor__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-1);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.btn--primary {
  border-color: var(--ink-1);
  background: var(--ink-1);
  color: var(--ink-on-bone);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn:focus-visible {
  outline: 2px solid var(--ink-2);
  outline-offset: 2px;
}

/* Narrow screens: the files and the plan drop under the sheet ---------------- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    padding-right: 24px;
  }

  .sheet {
    padding-bottom: 28px;
  }

  .side {
    padding-left: 0;
  }

  .files {
    width: 100%;
  }

  /* Under the sheet a plan keeps a readable size and scrolls sideways instead */
  .plan {
    position: static;
    overflow-x: auto;
  }

  .plan__stage {
    margin-inline: auto;
    width: min(100%, var(--plan-max));
    min-width: var(--plan-min);
  }
}

/* Phones: tighter gutters and columns so the four columns fit --------------- */

@media (max-width: 600px) {
  .session-bar {
    padding-inline: 16px;
    gap: 16px;
  }

  .session-bar__id {
    gap: 16px;
  }

  .session-bar__name {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .layout {
    padding-inline: 0;
  }

  .plan {
    margin-inline: 16px;
  }

  .rows__tie { width: 44px; }
  .rows__channel { width: 60px; }
  .rows__mic { width: 140px; }

  /* Larger rows to tap */
  .rows td {
    height: var(--tap);
  }

  /* At the top of the screen, clear of the keyboard */
  .editor {
    width: calc(100vw - 24px);
    margin-top: max(12px, env(safe-area-inset-top));
  }
}
