/* tresacords.cat — estils. Tokens presos del fitxer de Figma (mobile, 393px). */

/* ---------- Fonts ---------- */
@font-face {
  font-family: 'BDO Grotesk';
  src: url('../fonts/BDOGrotesk-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'BDO Grotesk';
  src: url('../fonts/BDOGrotesk-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'BDO Grotesk';
  src: url('../fonts/BDOGrotesk-DemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'BDO Grotesk';
  src: url('../fonts/BDOGrotesk-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Ms Paint Mouse';
  src: url('../fonts/MsPaintMouse-Accented.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Menorquina';
  src: url('../fonts/Menorquina-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #f0f0f0;
  --ink: #000;
  --blue: #1552ec;
  --tile: #ddd;
  --panel: #e1e1e1;
  --hairline: rgba(0, 0, 0, 0.1);
  --hairline-strong: rgba(0, 0, 0, 0.2);

  --dim: 0.6;
  --dimmer: 0.2;

  --font: 'BDO Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-hand: 'Ms Paint Mouse', 'Bradley Hand', 'Segoe Print', cursive;
  --font-quote: 'Menorquina', Georgia, serif;

  /* Escala tipogràfica del Figma */
  --t-logo: 17.28px;
  --t-hero: 20px;
  --t-xl: 34.56px;
  --t-lg: 23.04px;
  --t-md: 17.28px;
  --t-sm: 13.824px;
  --t-xs: 11.059px;

  --lh-sm: 24.96px;
  --lh-lg: 32.64px;

  --track: -0.06em;

  --gutter: 24px;
  --col: 393px;

  --wheel-h: 52px;
  --wheel-inset: 29px;
  --wheel-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  /* Cap flaix gris en tocar: el que es toca ja respon amb el seu propi
     `:active`, i el rectangle del sistema hi feia nosa. */
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  /* És una app de mòbil amb una sola columna: aquí no hi ha res per fer zoom.
     Treure el doble toc també treu l'espera de 300 ms abans de cada toc. */
  touch-action: manipulation;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  letter-spacing: var(--track);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Al Figma tot el text és BDO Grotesk Regular, també els titulars. */
h1,
h2,
h3,
blockquote {
  font-weight: 400;
  margin: 0;
}

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* Prémer una estona un acord o una fila no ha d'obrir el menú del sistema. */
a,
button {
  -webkit-touch-callout: none;
}

img {
  max-width: 100%;
  display: block;
}

::selection {
  background: var(--blue);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Estructura ---------- */
.shell {
  width: 100%;
  max-width: var(--col);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-top: 32px;
  padding-bottom: 40px;
}

.logo {
  display: block;
  font-family: var(--font-hand);
  font-size: var(--t-logo);
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 51px; /* logo a y=32, contingut a y=100 */
}

/* ---------- Home: portada ---------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 42px;
  padding-bottom: 22px;
}

.hero__claim {
  font-family: var(--font-hand);
  font-size: var(--t-hero);
  line-height: 30px;
  letter-spacing: -0.02em;
  color: var(--blue);
  text-align: center;
  margin: 0;
  text-wrap: balance;
}

.hero__art {
  width: 242.4px;
  height: 242.4px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

/* ---------- Home: col·leccions ---------- */
.collections {
  position: relative;
  margin-top: 38px;
}

.collections__row {
  display: flex;
  gap: 9.6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-block: 2px;
}

.collections__row::-webkit-scrollbar {
  display: none;
}

.collections::after {
  content: '';
  position: absolute;
  inset: -18px 0 -16px 0;
  pointer-events: none;
  background: linear-gradient(to right, rgba(240, 240, 240, 0) 69.7%, var(--bg));
}

.collection {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4.8px;
  flex: 0 0 auto;
  width: 72.8px;
  text-align: center;
}

.collection__art {
  width: 72.8px;
  height: 73.6px;
  border-radius: 8.8px;
  background: var(--tile);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: transform 0.16s ease;
}

.collection:active .collection__art {
  transform: scale(0.95);
}

.collection__art img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.collection__name {
  font-size: var(--t-xs);
  line-height: 12.8px;
}

.collection[aria-pressed='true'] .collection__art {
  background: var(--blue);
}

.collection[aria-pressed='true'] .collection__art img {
  mix-blend-mode: normal;
  filter: invert(1) brightness(2);
}

/* ---------- Home: pestanyes ---------- */
.tabs {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 38px;
}

.tab {
  font-size: var(--t-xl);
  line-height: 48px;
  letter-spacing: var(--track);
  opacity: var(--dimmer);
  transition: opacity 0.18s ease;
}

.tab--sub {
  font-size: var(--t-md);
  line-height: 33px;
}

.tab[aria-selected='true'] {
  opacity: 1;
}

/* ---------- Home: llista ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.list__letter {
  font-size: var(--t-xl);
  line-height: 48px;
  letter-spacing: var(--track);
  opacity: var(--dimmer);
}

.row {
  display: flex;
  align-items: flex-end;
  gap: 7.68px;
  min-height: 33px;
}

.row__title {
  font-size: var(--t-lg);
  line-height: var(--lh-lg);
  letter-spacing: var(--track);
}

.row__meta {
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  letter-spacing: var(--track);
  opacity: 0.55;
  white-space: nowrap;
}

.row:active .row__title {
  color: var(--blue);
}

.quote {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-block: 20px;
  color: var(--blue);
  text-align: right;
}

.quote__text {
  font-family: var(--font-quote);
  font-weight: 600;
  font-size: var(--t-lg);
  line-height: var(--lh-lg);
  letter-spacing: var(--track);
  margin: 0;
}

.quote__from {
  font-size: var(--t-xs);
  line-height: 19.968px;
}

.empty {
  opacity: 0.4;
  padding-block: 24px;
}

/* ---------- Cançó ---------- */
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.back img {
  width: 10.08px;
  height: 8.4px;
}

.song__head {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--blue);
  margin-top: 22px;
}

.song__title {
  font-size: var(--t-xl);
  line-height: 1.05;
  letter-spacing: var(--track);
  margin: 0;
}

.song__artist {
  font-size: var(--t-md);
  line-height: 33px;
  letter-spacing: var(--track);
}

/* ---------- La tira d'acords de la cançó ---------- */
/* Entre el títol i la lletra: els acords que faràs servir, en l'ordre que
   apareixen. Canvien sols quan es transposa la cançó o es canvia la notació. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.chips[hidden] {
  display: none;
}

.chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 8px 6px;
  background: none;
  border: 0;
  cursor: pointer;
  transition: transform 0.14s ease;
}

.chip:active {
  transform: scale(0.94);
}

.chip__head {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

/* La digitació, dins de la tira: es veu sense haver de tocar res. */
.chip__grid {
  display: block;
}

.chip__grid:empty {
  display: none;
}

.chip__grid svg {
  display: block;
  margin: 0 auto;
  width: 66.6px;
  height: 77.4px;
}

.chip__name {
  font-size: calc(var(--t-md) * 0.9);
  line-height: 1.25;
  letter-spacing: var(--track);
  color: var(--blue);
  white-space: nowrap;
}

.chip__degree {
  font-size: var(--t-xs);
  line-height: 1;
  opacity: 0.4;
}

.chip__degree:empty {
  display: none;
}

/* ---------- El globus amb la digitació ---------- */
.chordpop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  padding: 9px 12px 7px;
  background: #fff;
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.16);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92);
  transform-origin: center bottom;
  transition: opacity 0.14s ease, transform 0.16s cubic-bezier(0.2, 1.3, 0.4, 1),
    visibility 0.16s;
  pointer-events: none; /* és per mirar: el que hi ha a sota es pot continuar tocant */
}

.chordpop[data-open='true'] {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.chordpop__head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
}

.chordpop__name {
  font-size: var(--t-md);
  line-height: 1.2;
  letter-spacing: var(--track);
  color: var(--blue);
  white-space: nowrap;
}

.chordpop__degree {
  font-size: var(--t-xs);
  line-height: 1;
  opacity: 0.4;
}

.chordpop svg {
  display: block;
  margin: 4px auto 0;
}

.chordpop__missing {
  font-size: var(--t-xs);
  opacity: 0.4;
  margin: 6px 0 2px;
  max-width: 14em;
}

.song__body {
  margin-top: 22px;
  /* espai per a la roda i el botó flotants */
  padding-bottom: calc(var(--wheel-bottom) + 150px);
  /* La mida de la lletra es canvia des de les eines. Aquí redefinim els tokens
     de mida i tot el que hi ha a dins els hereta; a fora, la roda i el títol
     no es mouen. Amb --song-scale a 1 els valors són els mateixos del disseny. */
  --song-scale: 1;
  --t-sm: calc(13.824px * var(--song-scale));
  --t-xs: calc(11.059px * var(--song-scale));
  --lh-sm: calc(24.96px * var(--song-scale));
  font-size: var(--t-sm);
}

.block {
  margin: 0 0 var(--lh-sm) 0;
}

.block--chorus {
  border-left: 2px solid var(--hairline-strong);
  padding-left: 12px;
  margin-left: -14px;
}

.block--comment {
  font-size: var(--t-xs);
  line-height: calc(19.968px * var(--song-scale, 1));
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.block--tab {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: calc(12px * var(--song-scale, 1));
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  letter-spacing: 0;
}

/* Una línia de lletra: paraules que poden portar acord a sobre. */
.ln {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  column-gap: 0.3em;
  min-height: var(--lh-sm);
}

.ln--chorded {
  margin-top: 2px;
}

.w {
  display: inline-flex;
  align-items: flex-end;
}

.f {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}

.ch {
  display: block;
  font-size: var(--t-xs);
  font-weight: 500;
  line-height: calc(14px * var(--song-scale, 1));
  letter-spacing: -0.02em;
  color: var(--blue);
  white-space: nowrap;
  cursor: pointer;
  /* Una mica més de superfície per al dit, sense moure res de lloc: el que
     s'hi afegeix de coixí es descompta amb el marge. */
  padding: 5px 0.4em 3px 0;
  margin: -5px 0 -3px;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.14s ease;
}

.ch:active {
  opacity: 0.5;
}

/* Els claudàtors que marquen les parts de la cançó no són acords: es veuen,
   però no es toquen ni sonen. */
.ch--label {
  cursor: default;
}

.ch--label:active {
  opacity: 1;
}

.ly {
  display: block;
  line-height: var(--lh-sm);
  white-space: pre;
}

/* Un acord pot no tenir text a sota —al final de la línia, o just abans d'un
   espai—. Aleshores la caixa de la lletra es queda buida i, com que la línia
   s'alinea per baix, l'acord cauria a l'alçada de la lletra. Amb un espai de
   pas zero la caixa manté la seva alçada i l'acord es queda a dalt. */
.ly:empty::after {
  content: '\200b';
}

/* ---------- Roda d'acords ---------- */
.floaters {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  pointer-events: none;
}

.floaters__fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(118px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(240, 240, 240, 0) 0.42%, var(--bg) 76.2%);
}

.floaters__inner {
  position: relative;
  width: 100%;
  max-width: var(--col);
  margin-inline: auto;
  height: calc(var(--wheel-bottom) + var(--wheel-h) + 62px);
}

.pill-btn,
.wheel {
  pointer-events: auto;
  height: var(--wheel-h);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: 0 0 30.9px rgba(0, 0, 0, 0.12);
}

.pill-btn {
  width: var(--wheel-h);
  display: grid;
  place-items: center;
  transition: transform 0.16s ease, opacity 0.2s ease;
}

.pill-btn:active {
  transform: scale(0.94);
}

.pill-btn img {
  width: 100%;
  height: 100%;
}

/* Un botó que ara no fa res es veu, però apagat. */
.pill-btn[aria-disabled='true'] img {
  opacity: var(--dimmer);
}

.pill-btn[aria-disabled='true']:active {
  transform: none;
}

/* ---------- Eines ---------- */
/* La fila d'eines viu on hi havia el botó sol: alineada a la dreta, de manera
   que el «+» no es mou quan les altres apareixen o desapareixen. */
.tools {
  position: absolute;
  right: var(--wheel-inset);
  bottom: calc(var(--wheel-bottom) + var(--wheel-h) + 10px);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tancades ocupen lloc però no es veuen ni es poden tocar: `visibility` les
   treu també del recorregut del tabulador. */
.tools__opt {
  visibility: hidden;
  opacity: 0;
  transform: translateX(14px) scale(0.7);
  transition: opacity 0.16s ease, transform 0.24s cubic-bezier(0.2, 1.3, 0.4, 1),
    visibility 0.24s;
}

.tools[data-open='true'] .tools__opt {
  visibility: visible;
  opacity: 1;
  transform: none;
}

.tools[data-open='true'] .tools__opt:active {
  transform: scale(0.94);
}

/* Surten en cascada: primer la que és més a prop del «+». L'espera va a totes
   tres propietats alhora, també a `visibility`: així cap botó no es deixa
   tocar abans de veure's, ni es veu abans de deixar-se tocar. */
.tools[data-open='true'] .tools__opt:nth-child(3) {
  transition-delay: 0.02s;
}

.tools[data-open='true'] .tools__opt:nth-child(2) {
  transition-delay: 0.06s;
}

.tools[data-open='true'] .tools__opt:nth-child(1) {
  transition-delay: 0.1s;
}

/* El «+» gira quaranta-cinc graus i es converteix en creu. */
.tools__more img {
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.4, 1);
}

.tools[data-open='true'] .tools__more img {
  transform: rotate(45deg);
}

.wheel {
  position: absolute;
  left: var(--wheel-inset);
  right: var(--wheel-inset);
  bottom: var(--wheel-bottom);
  overflow: hidden;
  touch-action: pan-x;
}

.wheel__pill {
  position: absolute;
  left: 50%;
  top: 4px;
  transform: translateX(-50%);
  width: calc(var(--slot, 47.85px) * 3);
  height: 43px;
  background: #fff;
  border: 1px solid var(--hairline-strong);
  border-radius: 13px;
  box-shadow: 0 0 8.7px rgba(0, 0, 0, 0.05);
  pointer-events: none;
}

.wheel__track {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  /* Sense `scroll-snap`: el navegador enganxaria també les posicions que
     escriu el codi i es barallaria amb l'animació. Centrar l'acord quan
     l'usuari deixa anar ho fa song.js. */
  scrollbar-width: none;
  padding-inline: calc(var(--slot, 47.85px) * 3);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.wheel__track::-webkit-scrollbar {
  display: none;
}

.wheel__slot {
  flex: 0 0 var(--slot, 47.85px);
  width: var(--slot, 47.85px);
  height: 100%;
  display: grid;
  place-items: center;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  letter-spacing: var(--track);
  opacity: var(--dimmer);
  transition: opacity 0.18s ease;
  white-space: nowrap; /* «Sol♯» és més llarg que «G♯» */
  position: relative;
  z-index: 1;
  cursor: pointer;
}

.wheel__slot[data-near='1'] {
  opacity: 1;
}

.wheel__slot[data-near='2'] {
  opacity: var(--dim);
}

/* ---------- Full de digitacions ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  justify-items: center;
  background: rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
}

.sheet[data-open='true'] {
  opacity: 1;
  visibility: visible;
}

.sheet__panel {
  width: 100%;
  max-width: var(--col);
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--hairline);
  padding: 18px var(--gutter) calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateY(14px);
  transition: transform 0.22s ease;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.1);
}

.sheet[data-open='true'] .sheet__panel {
  transform: none;
}

.sheet__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet__title {
  font-size: var(--t-lg);
  line-height: var(--lh-lg);
  letter-spacing: var(--track);
  margin: 0;
}

.sheet__close {
  font-size: var(--t-sm);
  opacity: 0.5;
}

.diagrams {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.diagram {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 13px;
  padding: 10px 6px 8px;
  text-align: center;
  cursor: pointer; /* tocar-la la fa sonar */
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.14s ease;
}

.diagram:active {
  transform: scale(0.96);
}

.diagram__name {
  font-size: var(--t-md);
  line-height: 1.2;
  letter-spacing: var(--track);
  color: var(--blue);
}

.diagram__degree {
  font-size: var(--t-xs);
  line-height: 14px;
  opacity: 0.4;
}

.diagram svg {
  margin: 6px auto 0;
}

.diagram__missing {
  font-size: var(--t-xs);
  opacity: 0.4;
  padding-block: 22px;
}

/* ---------- Detalls ---------- */
@media (hover: hover) {
  .row:hover .row__title,
  .back:hover {
    color: var(--blue);
  }
  .wheel__slot:hover {
    opacity: 0.85;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
