/* The public song sheet: ONE shell for the shared chart page and /try (app/views/public/sheets/_shell). It is the member song
   sheet (perform_songview.css, songview_controls.css) with a brand bar on top, a song header and a brand block after the last
   line. It follows the visitor's appearance through the app tokens. The mustard action is the one solid colour block,
   allowed because this is a public brand surface. Colours only through tokens. */
/* No jump when the real fonts arrive: while Alfa Slab One and Atkinson Hyperlegible Next load (font-display: swap in
   tokens.css), the page sets in a local face scaled to match their width and line box. The two public pages put these
   faces first in their own stacks; the rest of the app is unchanged. */
@font-face {
  font-family: "Alfa Slab One Fallback";
  src: local("Georgia");
  font-weight: 400;
  size-adjust: 112%;
  ascent-override: 88%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Atkinson Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Liberation Sans");
  font-weight: 400 700;
  size-adjust: 103%;
  ascent-override: 93%;
  descent-override: 24%;
  line-gap-override: 0%;
}

body.public-interface,
body.share-interface {
  --font-display: "Alfa Slab One", "Alfa Slab One Fallback", Fraunces, Georgia, serif;
  --font-ui: "Atkinson Hyperlegible Next", "Atkinson Fallback", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root {
  --sheet-bar-h: 56px;
}

/* ---------------------------------------------------------------------------------------------------------------
   Brand bar: charcoal in both appearances, the three-band stripe running through the middle (behind the logo plate and
   the action plate), mark and wordmark left, ONE mustard action right.
   --------------------------------------------------------------------------------------------------------------- */
.sheet-bar {
  position: relative;
  z-index: 5;
  display: flex;
  height: var(--sheet-bar-h);
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 clamp(10px, 2.5vw, 24px);
  border-bottom: 2px solid var(--chrome-edge);
  color: var(--chrome-ink);
  background: var(--chrome-bg);
}

.sheet-bar__stripe {
  --band: 4px;
  --gap: 2px;
  position: absolute;
  top: calc(50% - (var(--band) * 3 + var(--gap) * 2) / 2);
  right: 0;
  left: 0;
  height: calc(var(--band) * 3 + var(--gap) * 2);
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--stripe-1) 0 var(--band),
    transparent var(--band) calc(var(--band) + var(--gap)),
    var(--stripe-2) calc(var(--band) + var(--gap)) calc(var(--band) * 2 + var(--gap)),
    transparent calc(var(--band) * 2 + var(--gap)) calc(var(--band) * 2 + var(--gap) * 2),
    var(--stripe-3) calc(var(--band) * 2 + var(--gap) * 2) calc(var(--band) * 3 + var(--gap) * 2)
  );
}

.sheet-bar__brand,
.sheet-bar__action {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100%;
  align-items: center;
  background: var(--chrome-bg);
}

.sheet-bar__brand {
  gap: 10px;
  padding-right: 18px;
  color: var(--chrome-ink);
  text-decoration: none;
}

.sheet-bar__brand:focus-visible,
.sheet-bar .sheet-cta:focus-visible,
.sheet-bar summary:focus-visible {
  outline: 3px solid var(--chrome-focus);
  outline-offset: 3px;
}

.sheet-bar__word {
  min-width: 0;
  overflow: hidden;
  font: 400 1.2rem/1 var(--font-display);
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-bar__action {
  padding-left: 16px;
}

.sheet-bar__action {
  gap: 16px;
}

/* Tablet and desktop only: on a phone the bar keeps just the mark and the one mustard action. */
.sheet-bar__secondary {
  display: none;
}

.sheet-bar__secondary a {
  color: var(--chrome-ink);
  font: 700 0.95rem/1 var(--font-ui);
  text-decoration: underline;
  text-decoration-color: var(--chrome-outline);
  text-underline-offset: 0.3em;
  white-space: nowrap;
}

.sheet-bar__secondary a:hover {
  text-decoration-color: currentColor;
}

@media screen and (min-width: 48rem) {
  .sheet-bar__secondary {
    display: flex;
  }

  .sheet-bar__secondary a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
  }
}

.sheet-bar__action form {
  margin: 0;
}

/* The wordmark gives way before the action does: on a phone the mark alone, as in the member bar. */
@media screen and (max-width: 33.99rem) {
  .sheet-bar__word {
    display: none;
  }

  .sheet-bar__brand {
    padding-right: 12px;
  }
}

/* The action: teal outline with a pastel fill. Mustard is reserved for Quick add and Print. */
.sheet-cta {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--selected-line);
  border-radius: var(--radius-control);
  color: var(--selected-ink);
  background: var(--selected-fill);
  font: 700 0.98rem/1 var(--font-ui);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

@media screen and (max-width: 33.99rem) {
  .sheet-bar .sheet-cta {
    min-height: 40px;
    padding: 0 14px;
    font-size: 0.92rem;
  }
}

.sheet-cta:hover { background: var(--selected-fill); }

/* The sheet bar is always charcoal: its teal outline uses the dark (fixed) teal pair. */
.sheet-bar .sheet-cta:not(.sheet-cta--quiet),
.sheet-bar .sheet-cta:not(.sheet-cta--quiet):hover {
  border-color: var(--stage-fixed-selected-line);
  color: var(--stage-fixed-selected-ink);
  background: var(--stage-fixed-selected-fill);
}

.sheet-cta--quiet {
  color: var(--ink);
  background: transparent;
  border-color: var(--hairline);
}

.sheet-bar .sheet-cta--quiet {
  color: var(--chrome-ink);
  border-color: var(--chrome-outline);
}

.sheet-keep {
  position: static;
}

.sheet-keep > summary {
  list-style: none;
}

.sheet-keep > summary::-webkit-details-marker {
  display: none;
}

.sheet-keep__panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: clamp(8px, 2vw, 20px);
  width: min(24rem, calc(100vw - 16px));
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-floating);
}

.sheet-keep__panel form,
.sheet-keep__inline {
  display: grid;
  gap: 12px;
}

.sheet-keep__inline {
  max-width: 26rem;
  text-align: left;
}

/* ---------------------------------------------------------------------------------------------------------------
   Song header: first thing in the chart area (it scrolls away with the page; the bar and the controls stay).
   --------------------------------------------------------------------------------------------------------------- */
.sheet-song {
  display: grid;
  width: min(84rem, 100%);
  justify-items: start;
  gap: 6px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 40px) clamp(1rem, 3vw, 2rem) clamp(8px, 2vw, 16px);
}

/* Artist and key on one line (they wrap on a narrow phone): the chart starts higher on the first screen. */
.sheet-song__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.sheet-song__title {
  justify-self: stretch;
  max-width: 100%;
  margin: 0;
  color: var(--ink);
  font: 400 clamp(1.9rem, 1.2rem + 3.2vw, 3rem)/1.08 var(--font-display);
  letter-spacing: 0.005em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.sheet-song__artist {
  margin: 0;
  color: var(--muted);
  font: 400 clamp(1.05rem, 1rem + 0.5vw, 1.35rem)/1.3 var(--font-ui);
}

/* Coral is the key badge colour: an outline with a pastel fill, never a block. */
.sheet-song__key {
  margin: 0;
  padding: 4px 12px;
  border: 1px solid var(--key-line);
  border-radius: var(--radius-pill);
  color: var(--key-ink);
  background: var(--key-fill);
  font: 700 0.9rem/1.2 var(--font-ui);
}

.sheet-song__via {
  margin: 4px 0 0;
  color: var(--muted);
  font: 400 0.82rem/1.3 var(--font-ui);
}

.sheet-song .chart-links {
  margin-top: 6px;
}

/* The action row under the header: quiet outline buttons (never a second solid block). Print is on both pages; /try adds
   Edit text and the Save menu. */
.sheet-song__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

/* Tablet and up: the actions sit at the right of the header, level with the title; the phone keeps them under it. */
@media screen and (min-width: 48rem) {
  .sheet-song {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 24px;
  }

  .sheet-song > * {
    grid-column: 1;
  }

  .sheet-song > .sheet-song__actions {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    margin-top: 0;
    align-self: start;
  }

  .sheet-song .sheet-menu__panel {
    right: 0;
    left: auto;
  }
}

.sheet-action {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  color: var(--ink);
  background: var(--surface);
  font: 700 0.95rem/1 var(--font-ui);
  white-space: nowrap;
  cursor: pointer;
}

.sheet-action:hover {
  background: var(--tint);
}

.sheet-action .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.sheet-menu {
  position: relative;
}

.sheet-menu__summary {
  list-style: none;
}

.sheet-menu__summary::-webkit-details-marker {
  display: none;
}

.sheet-menu__panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  min-width: min(16rem, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-floating);
}

.sheet-menu__item {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--ink);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sheet-menu__item:hover,
.sheet-menu__item:focus-visible {
  background: var(--tint);
}

.sheet-menu__item .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.sheet-menu__note {
  margin: 4px 12px 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* The chords strip lines up with the header, not with the screen edge. */
.public-sheet .fg-tools {
  width: min(84rem, 100%);
  margin: 0 auto;
  padding-inline: clamp(0.5rem, 2.4vw, 1.5rem);
}

.public-sheet .key-banner {
  width: min(84rem, 100%);
  margin: 0 auto;
  padding-inline: clamp(1rem, 3vw, 2rem);
}

/* ---------------------------------------------------------------------------------------------------------------
   Brand block after the last line (inside the scrolling area, never over the chart).
   --------------------------------------------------------------------------------------------------------------- */
.sheet-brand {
  display: grid;
  width: min(40rem, calc(100% - 32px));
  justify-items: center;
  gap: 16px;
  margin: clamp(32px, 6vw, 56px) auto 0;
  padding: clamp(28px, 5vw, 44px) 0 clamp(36px, 6vw, 56px);
  border-top: 2px solid var(--heading-rule);
  color: var(--ink);
  text-align: center;
}

.sheet-brand__mark {
  --brand-badge-size: 56px;
  --brand-mark-height: 42px;
}

.sheet-brand__line {
  max-width: 24ch;
  margin: 0;
  font: 400 clamp(1.35rem, 1.1rem + 1.2vw, 1.85rem)/1.2 var(--font-display);
  text-wrap: balance;
}

.sheet-brand__action {
  display: grid;
  justify-items: center;
}

.sheet-brand__action {
  gap: 12px;
}

/* The invitation to the other page: an outline (never a second solid block), the question in bold, the promise after it. */
.sheet-brand__try {
  display: grid;
  min-height: 48px;
  gap: 2px;
  padding: 10px 22px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  font: 400 0.98rem/1.25 var(--font-ui);
  text-decoration: none;
}

.sheet-brand__try b {
  font-weight: 700;
}

.sheet-brand__try:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.sheet-brand__action form {
  margin: 0;
}

.sheet-brand__action .sheet-cta {
  min-height: 48px;
  padding: 0 26px;
  font-size: 1.05rem;
}

.sheet-brand__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  margin: 0;
  color: var(--muted);
  font: 400 0.95rem/1.3 var(--font-ui);
}

.sheet-brand__links a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0 4px;
  border: 0;
  color: var(--accent);
  background: transparent;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

/* ---------------------------------------------------------------------------------------------------------------
   Pages with no chart (a link that is gone) and the shared set page share the bar.
   --------------------------------------------------------------------------------------------------------------- */
.shared-unavailable-page .shared-unavailable {
  min-height: calc(100dvh - var(--sheet-bar-h));
}

.shared-unavailable__home {
  color: var(--accent);
}

.share-interface .shared-unavailable h1,
.share-interface .shared-set__header h1 { font-weight: 400; letter-spacing: 0.01em; }
