/* ==========================================================================
   Zauk Digital Songbook
   A lyrics companion read on a phone, in a dim room, while a band is playing.
   Everything here is in service of: read a line, look back up at the stage.
   ========================================================================== */

:root {
  --sb-bg:      #211B19;
  --sb-surface: #2D2521;
  --sb-text:    #F5EBDD;
  --sb-text2:   #D0BBA6;
  /* The brief's #B96B3C reaches only 4.23:1 on this background, short of the
     4.5 AA needs for the small uppercase labels it is used for. Lightened to
     the nearest tone that passes (5.31 on bg, 4.69 on surface). */
  --sb-accent:  #C87E52;
  --sb-line:    rgba(245, 235, 221, .13);
  --sb-shade:   rgba(245, 235, 221, .05);

  --sb-head: 56px;
  --sb-foot: 56px;
  --sb-pad: clamp(18px, 5vw, 22px);
  --sb-read: 680px;

  --f-lyric: "Cormorant Garamond", Georgia, serif;
  --f-ui: "Jost", system-ui, -apple-system, sans-serif;

  color-scheme: dark;
}

:root[data-sb-theme="light"] {
  --sb-bg:      #F7F0E5;
  --sb-surface: #EFE6D8;
  --sb-text:    #30251F;
  --sb-text2:   #685346;
  /* likewise: the brief's #A75C30 gives 4.40:1 here */
  --sb-accent:  #9C5429;
  --sb-line:    rgba(48, 37, 31, .15);
  --sb-shade:   rgba(48, 37, 31, .04);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--sb-head) + 12px); }

body {
  margin: 0;
  background: var(--sb-bg);
  color: var(--sb-text);
  font-family: var(--f-ui);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--sb-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.sb-skip {
  position: absolute;
  left: 12px; top: -70px;
  z-index: 60;
  padding: 10px 16px;
  background: var(--sb-surface);
  color: var(--sb-text);
  font-size: 13px;
  transition: top .2s ease;
}
.sb-skip:focus { top: 12px; }

.sb-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.sb-wrap {
  max-width: var(--sb-read);
  margin: 0 auto;
  padding-inline: var(--sb-pad);
}

/* --- Library ------------------------------------------------------------- */
.sb-lib {
  padding-top: calc(28px + env(safe-area-inset-top));
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}
.sb-lib__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.sb-lib__brand img { height: 15px; width: auto; display: block; opacity: .9; }
.sb-lib__title {
  margin: clamp(26px, 7vw, 38px) 0 0;
  font-family: var(--f-lyric);
  font-weight: 500;
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.12;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.sb-lib__sub {
  margin: 8px 0 0;
  font-size: 13px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--sb-text2);
}

.sb-search { position: relative; margin-top: clamp(24px, 6vw, 32px); }
.sb-search input {
  width: 100%;
  padding: 15px 16px 15px 44px;
  background: var(--sb-surface);
  border: 1px solid var(--sb-line);
  border-radius: 10px;
  color: var(--sb-text);
  font-family: var(--f-ui);
  font-size: 16px;            /* 16px keeps iOS from zooming on focus */
  font-weight: 300;
}
.sb-search input::placeholder { color: var(--sb-text2); opacity: .85; }
.sb-search input:focus { border-color: var(--sb-accent); outline: none; }
.sb-search svg {
  position: absolute;
  left: 15px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  fill: none; stroke: var(--sb-text2);
  stroke-width: 1.6;
  pointer-events: none;
}

.sb-list { margin: 10px 0 0; padding: 0; list-style: none; }
.sb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 2px;
  min-height: 56px;
  border-bottom: 1px solid var(--sb-line);
}
.sb-row:hover { background: var(--sb-shade); }
.sb-row__n {
  flex: none;
  width: 26px;
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--sb-accent);
  font-variant-numeric: tabular-nums;
}
.sb-row__main { flex: 1; min-width: 0; }
.sb-row__title {
  display: block;
  font-family: var(--f-lyric);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.25;
  color: var(--sb-text);
}
.sb-row__by {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--sb-text2);
}
.sb-row__chev { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--sb-text2); stroke-width: 1.6; }
.sb-empty { padding: 30px 2px; color: var(--sb-text2); font-size: 15px; }

.sb-note-lib {
  margin: 30px 0 0;
  padding: 14px 16px;
  background: var(--sb-surface);
  border-left: 2px solid var(--sb-accent);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--sb-text2);
}

/* --- Reader header -------------------------------------------------------- */
.sb-head {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--sb-bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sb-line);
  padding-top: env(safe-area-inset-top);
}
.sb-head__in {
  height: var(--sb-head);
  max-width: var(--sb-read);
  margin: 0 auto;
  padding-inline: max(8px, calc(var(--sb-pad) - 10px));
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 4px;
}
.sb-ico {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: none; border: 0; padding: 0;
  color: var(--sb-text);
  cursor: pointer;
}
.sb-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sb-head__title {
  margin: 0;
  min-width: 0;
  background: none; border: 0; padding: 0 2px;
  font-family: var(--f-lyric);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.2;
  color: var(--sb-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* --- Reader body ---------------------------------------------------------- */
.sb-read {
  padding-top: clamp(22px, 6vw, 30px);
  /* the fixed footer must never sit on top of the last line */
  padding-bottom: calc(var(--sb-foot) + env(safe-area-inset-bottom) + 44px);
}
.sb-read__credits {
  margin: 0 0 clamp(22px, 6vw, 30px);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--sb-text2);
}

.sb-sec { margin-top: clamp(26px, 7vw, 36px); }
.sb-sec:first-of-type { margin-top: 0; }
.sb-sec__h {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--sb-accent);
}
/* a chorus should be findable at a glance, without boxing every verse */
.sb-sec--chorus { padding-left: 14px; border-left: 2px solid var(--sb-accent); }
.sb-sec--chorus .sb-sec__h { font-weight: 500; letter-spacing: .26em; }

.sb-line { margin-top: 20px; }
.sb-line:first-of-type { margin-top: 0; }
.sb-line__o {
  margin: 0;
  font-family: var(--f-lyric);
  font-weight: 500;
  font-size: clamp(20px, 5.4vw, 23px);
  line-height: 1.38;
  color: var(--sb-text);
}
.sb-line__e {
  margin: 5px 0 0;
  font-size: clamp(15px, 4.1vw, 16px);
  font-weight: 300;
  line-height: 1.5;
  color: var(--sb-text2);
}

.sb-mean {
  margin: 16px 0 0;
  padding: 12px 14px;
  background: var(--sb-surface);
  border-left: 2px solid var(--sb-accent);
  border-radius: 0 4px 4px 0;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.62;
  color: var(--sb-text2);
}
.sb-mean b {
  font-weight: 500;
  color: var(--sb-accent);
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 5px;
}
/* extra notes stay in the markup and appear when the reader asks for them */
.sb-mean--extra { display: none; }
:root[data-sb-notes="all"] .sb-mean--extra { display: block; }

/* --- Songs without reproduced lyrics -------------------------------------- */
.sb-guide { margin-top: clamp(24px, 6vw, 32px); }
.sb-guide__h {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--sb-accent);
}
.sb-guide__s {
  margin: 0;
  font-family: var(--f-lyric);
  font-weight: 500;
  font-size: clamp(18px, 4.8vw, 20px);
  line-height: 1.4;
  color: var(--sb-text);
}
.sb-guide__m { margin: 8px 0 0; font-size: 14px; font-weight: 300; line-height: 1.62; color: var(--sb-text2); }

/* --- Fixed bottom navigation ---------------------------------------------- */
.sb-foot {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--sb-bg) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--sb-line);
  padding-bottom: env(safe-area-inset-bottom);
}
.sb-foot__in {
  height: var(--sb-foot);
  max-width: var(--sb-read);
  margin: 0 auto;
  padding-inline: max(8px, calc(var(--sb-pad) - 10px));
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
}
.sb-nav {
  width: 56px; height: 44px;
  display: grid; place-items: center;
  color: var(--sb-text);
}
.sb-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sb-nav[aria-disabled="true"] { opacity: .3; pointer-events: none; }
.sb-pos {
  text-align: center;
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--sb-text2);
  font-variant-numeric: tabular-nums;
}

/* --- Song picker ---------------------------------------------------------- */
.sb-sheet {
  position: fixed; inset: 0;
  z-index: 50;
}
/* hidden via the attribute alone: the panel must be focusable the moment it is
   un-hidden, a frame before .is-open starts the slide-up */
.sb-sheet[hidden] { display: none; }
.sb-sheet__veil {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .55);
  opacity: 0;
  transition: opacity .25s ease;
}
.sb-sheet.is-open .sb-sheet__veil { opacity: 1; }
.sb-sheet__panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 88svh;
  display: flex; flex-direction: column;
  background: var(--sb-bg);
  border-top: 1px solid var(--sb-line);
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sb-sheet.is-open .sb-sheet__panel { transform: none; }
.sb-sheet__grab {
  width: 38px; height: 4px;
  margin: 10px auto 0;
  border-radius: 2px;
  background: var(--sb-line);
}
.sb-sheet__bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px var(--sb-pad) 0;
}
.sb-sheet__bar h2 {
  margin: 0;
  font-family: var(--f-lyric);
  font-weight: 500;
  font-size: 20px;
}
.sb-sheet__body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 var(--sb-pad) 10px; }
.sb-sheet .sb-search { margin: 14px 0 0; }
.sb-row--now { background: var(--sb-shade); }
.sb-row--now .sb-row__title { color: var(--sb-accent); }

.sb-prefs {
  border-top: 1px solid var(--sb-line);
  padding: 12px var(--sb-pad) 14px;
  display: flex; flex-wrap: wrap; gap: 10px 22px;
}
.sb-pref { display: flex; align-items: center; gap: 10px; }
.sb-pref > span {
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--sb-text2);
}
.sb-seg { display: flex; border: 1px solid var(--sb-line); border-radius: 999px; overflow: hidden; }
.sb-seg button {
  min-height: 34px;
  padding: 0 14px;
  background: none; border: 0;
  color: var(--sb-text2);
  font-family: var(--f-ui);
  font-size: 12px;
  letter-spacing: .06em;
  cursor: pointer;
}
.sb-seg button[aria-pressed="true"] { background: var(--sb-accent); color: var(--sb-bg); }

body.sb-locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .sb-sheet__panel, .sb-sheet__veil { transition: none; }
}
