/* Reference dashboard and host-screen interaction study. */

body {
  min-height: 100vh;
  min-height: 100dvh;
}

code {
  font-family: inherit;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink-raised);
  padding: 0.05em 0.35em;
  border-radius: 2px;
}

/* ---------- Host study ---------- */

.host {
  position: fixed;
  inset: 0;
  background-color: var(--ink-sunk);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(243, 234, 217, 0.04) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(243, 234, 217, 0.04) 47px 48px);
}

.host__surface {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 4rem var(--gutter);
}

.host__copy {
  max-width: 32rem;
  display: grid;
  gap: 1rem;
  color: var(--paper-dim);
}

.host__copy h2 {
  font-size: var(--t-24);
  color: var(--paper);
}

/* Same corner as the dashboard's Back button, so open and close live in one place. */
.host__badge {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
}

/* ---------- Dashboard frame ---------- */

.dash {
  max-width: 88rem;
  margin: 0 auto;
  padding: 0 var(--gutter) 3rem;
  outline: none;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin: 0 calc(var(--gutter) * -1);
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 8px var(--gutter);
  background: var(--ink);
  border-bottom: 1px solid var(--line);
}

.bar__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.bar__mark {
  width: 24px;
  height: 24px;
  flex: none;
  fill: var(--signal);
}

.bar h1 {
  font-size: var(--t-21);
  white-space: nowrap;
}

.bar__sub {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--t-16);
  letter-spacing: 0;
  color: var(--paper-dim);
}

.bar__source {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  font-weight: 600;
}

.source-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-age {
  color: var(--paper-dim);
  font-weight: 500;
  white-space: nowrap;
}

/* The dot is a small Phasefold-like diamond: filled when connected, hollow otherwise. */
.source-dot {
  flex: none;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  box-shadow: inset 0 0 0 2px var(--paper-dim);
}

body[data-connection="connected"] .source-dot {
  background: var(--signal);
  box-shadow: none;
}

body[data-connection="stale"] .source-dot {
  box-shadow: inset 0 0 0 2px var(--signal);
}

body[data-source="demo"] .source-dot {
  background: var(--sim);
  box-shadow: none;
}

.bar__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}

.bar__back kbd {
  border-color: var(--line-strong);
}

.notice {
  max-width: 62rem;
  margin: 1.25rem 0 0;
  padding-left: 0.9rem;
  border-left: 3px solid var(--line-strong);
  color: var(--paper-dim);
  font-size: var(--t-14);
}

/* ---------- Simulated demo: impossible to miss ---------- */

.sim-banner {
  position: sticky;
  top: var(--bar-height, 61px);
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin: 0 calc(var(--gutter) * -1);
  padding: 0.75rem var(--gutter);
  background: var(--ink);
  color: var(--sim);
  font-size: var(--t-18);
  border-bottom: 6px solid transparent;
  border-image: repeating-linear-gradient(-45deg, var(--sim) 0 10px, var(--ink) 10px 20px) 6;
}

.sim-banner strong {
  font-family: var(--font-brand);
}

body[data-source="demo"]::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  border: 4px solid var(--sim);
}

body[data-source="demo"] .deck {
  --accent: var(--sim);
}

/* ---------- Sections ---------- */

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  margin: 2.25rem 0 1rem;
}

.section-head h2 {
  font-size: var(--t-36);
}

.section-note {
  max-width: 34rem;
  color: var(--paper-dim);
  font-size: var(--t-14);
}

.decks {
  outline: none;
}

.empty {
  display: grid;
  gap: 0.75rem;
  max-width: 40rem;
  padding: 2.5rem 0 2.5rem 1.5rem;
  border-left: 3px solid var(--line-strong);
}

.empty h3 {
  font-size: var(--t-24);
}

.empty p {
  color: var(--paper-dim);
}

.empty__actions {
  margin-top: 0.5rem;
}

body[data-connection="incompatible"] .empty {
  border-left-color: var(--signal);
}

/* ---------- Deck strip: one instrument, divided like a mixer ---------- */

.strip {
  --accent: var(--signal);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.strip[data-layout="grid"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.deck {
  --accent: var(--signal);
  display: grid;
  align-content: start;
  gap: 1.1rem;
  padding: 1.25rem 1.25rem 1rem;
  background: var(--ink);
  min-width: 0;
}

.deck__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.deck__name {
  font-size: var(--t-21);
}

.deck__gen {
  color: var(--paper-dim);
  font-size: var(--t-14);
}

.deck__phase {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Bar phase traced around the Phasefold mark: continuous, starting at the top gap. */
.phase {
  --p: 0;
  flex: none;
  width: 84px;
  height: 84px;
  background: conic-gradient(var(--accent) calc(var(--p) * 1turn), var(--line-strong) 0);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M2 2H14L10 6H6V10L2 14Z M30 2V14L26 10V6H22L18 2Z M30 30H18L22 26H26V22L30 18Z M2 30V18L6 22V26H10L14 30Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M2 2H14L10 6H6V10L2 14Z M30 2V14L26 10V6H22L18 2Z M30 30H18L22 26H26V22L30 18Z M2 30V18L6 22V26H10L14 30Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.phase[data-unknown] {
  background: repeating-linear-gradient(-45deg, var(--line-strong) 0 2px, transparent 2px 6px);
}

.phase__text {
  color: var(--paper-dim);
  font-size: var(--t-14);
  line-height: 1.35;
}

.phase__text strong {
  display: inline-block;
  margin-top: 0.15rem;
  color: var(--paper);
  font-size: var(--t-21);
  font-weight: 600;
}

.deck__tempo {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--font-brand);
  font-size: var(--t-48);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.deck__unit {
  font-family: var(--font-ui);
  font-size: var(--t-14);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--paper-dim);
}

.is-unknown {
  color: var(--paper-dim);
  font-weight: 500;
}

.deck__tempo .is-unknown {
  font-size: var(--t-24);
}

.deck__facts {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--line);
}

.deck__facts > div,
.facts > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}

.deck__facts dt,
.facts dt {
  color: var(--paper-dim);
}

.deck__facts dd,
.facts dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

.transport::before {
  display: inline-block;
  width: 1.1em;
  margin-right: 0.3rem;
  text-align: center;
  color: var(--paper-dim);
}

.transport[data-state="playing"]::before {
  content: "\25B6";
  color: var(--accent);
}

.transport[data-state="paused"]::before {
  content: "\2016";
}

.transport[data-state="stopped"]::before {
  content: "\25A0";
}

.transport[data-state="unknown"]::before {
  content: "?";
}

.onair[data-state="true"] {
  color: var(--accent);
}

.deck__fresh {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: var(--t-14);
  color: var(--paper-dim);
}

.deck__prov {
  overflow-wrap: anywhere;
}

/* Not fresh: the values stay readable but recede. */
.deck[data-fresh="false"] .deck__tempo,
.deck[data-fresh="false"] .deck__facts dd,
.deck[data-fresh="false"] .phase__text strong {
  color: var(--paper-dim);
}

.deck[data-fresh="false"] .phase {
  --accent: var(--paper-dim);
}

/* ---------- Lower panels ---------- */

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 2rem 3rem;
  margin-top: 3rem;
}

.panel {
  border-top: 2px solid var(--line-strong);
  padding-top: 1rem;
}

.panel h2 {
  font-size: var(--t-21);
  margin-bottom: 0.75rem;
}

.facts {
  margin: 0;
}

.facts dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.facts-extra,
.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.facts-extra li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--paper-dim);
}

.entries li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.entry__title {
  font-weight: 600;
}

.entry__details {
  margin-top: 0.15rem;
  color: var(--paper-dim);
  font-size: var(--t-14);
}

.panel__empty {
  color: var(--paper-dim);
}

.warnings {
  margin-top: 1rem;
  color: var(--paper-dim);
  font-size: var(--t-14);
}

.warnings summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--paper);
}

.warnings ul {
  margin: 0;
  padding-left: 1.1rem;
}

.dash-foot {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--paper-dim);
  font-size: var(--t-14);
}

/* ---------- Settings sheet ---------- */

.settings {
  width: min(32rem, 100vw);
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0 1.5rem 2rem;
  border: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--ink);
  color: var(--paper);
  overflow-y: auto;
}

.settings::backdrop {
  background: rgba(21, 18, 14, 0.72);
}

.settings__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
}

.settings__head h2 {
  font-size: var(--t-24);
}

.settings__group {
  display: grid;
  gap: 0.75rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

.settings__group h3 {
  font-size: var(--t-18);
}

.settings__note {
  color: var(--paper-dim);
  font-size: var(--t-14);
}

.field {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.field__label {
  font-weight: 600;
}

.field select,
.field input[type="url"] {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--ink-sunk);
  color: var(--paper);
  font: inherit;
}

.field--choice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}

.field--choice legend {
  width: 100%;
  margin-bottom: 0.25rem;
}

.field--choice label,
.field--check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  cursor: pointer;
}

.field input[type="radio"],
.field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--signal);
}

.field__error {
  color: var(--signal);
  font-weight: 600;
}

.deferred {
  display: grid;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--signal);
  background: var(--ink-raised);
}

.deferred__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.unavailable {
  list-style: none;
  margin: 0;
  padding: 0;
}

.unavailable li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  color: var(--paper-dim);
}

/* ---------- Small screens and touch ---------- */

@media (max-width: 760px) {
  .bar {
    grid-template-columns: 1fr auto;
  }

  .bar__source {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .bar__sub {
    display: none;
  }

  .bar__back kbd {
    display: none;
  }

  .strip[data-layout="grid"] {
    grid-template-columns: 1fr;
  }

  .section-head h2 {
    font-size: var(--t-24);
  }

  .deck__tempo {
    font-size: var(--t-36);
  }
}
