/* GlassLyrics -- Meta Ray-Ban Display (600x600 waveguide).
   Pure white on pure black: the waveguide is additive, so black pixels are
   simply "off". No gradients, no shadows, no animation beyond opacity fades. */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* The .notice / .pair rules below set display:flex, which outranks the user
   agent's [hidden] { display: none }. Without this the hidden panels keep
   occupying their grid rows and push the metadata header off the display. */
[hidden] { display: none !important; }

:root {
  --fg: #ffffff;
  --dim: #9a9a9a;
  --faint: #565656;
  --pad: 26px;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  color: var(--fg);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  font-weight: 600;
  /* Waveguide optics smear thin strokes; a touch of tracking keeps them apart. */
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 600px;
  max-height: 600px;
  margin: 0 auto;
  padding: var(--pad);
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* minmax(0, 1fr) rather than an implicit auto track: an auto column sizes to
     content, which let a long lyric line blow the layout out past 600px. */
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

/* ------------------------------------------------------------ metadata */

.meta { text-align: center; min-height: 52px; }

.meta-title {
  font-size: 25px;
  line-height: 1.15;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-artist {
  font-size: 21px;
  line-height: 1.2;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* -------------------------------------------------------------- lyrics */

.lyrics {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  /* Both min-* are required: a grid item defaults to min-width/height:auto,
     which is its min-content size. One unbreakable long word would otherwise
     stretch this container far past 600px and push the text off-screen. */
  min-height: 0;
  min-width: 0;
  text-align: center;
}

.line {
  width: 100%;
  overflow: hidden;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  min-width: 0;
  transition: opacity 120ms linear;
}

/* The clamp lives on an inner span, never on the flex item itself: a
   -webkit-box that is a direct flex child gets blockified to flow-root,
   which silently disables both the clamp and normal text wrapping. */
.clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
}

.line-prev {
  font-size: 24px;
  line-height: 1.2;
  color: var(--faint);
  font-weight: 500;
}

.line-current {
  /* Size is recalculated per line in JS; this is the ceiling. */
  font-size: 58px;
  line-height: 1.14;
  font-weight: 700;
  color: var(--fg);
}

.line-next {
  font-size: 30px;
  line-height: 1.2;
  color: var(--dim);
  font-weight: 500;
}

/* ---------------------------------------------------------------- ruby */

/* Furigana sits above the base text, so the lyric box needs headroom or the
   readings are clipped by the container. This is reserved space, not padding
   that moves: the amount is proportional to the current font size. */
.line-current { padding-top: 0.55em; }

.tok {
  /* Keeping a token whole stops a wrap landing between a kanji and its ruby. */
  display: inline-block;
  white-space: normal;
}

ruby {
  ruby-position: over;
  -webkit-ruby-position: before;
  ruby-align: center;
}

rt {
  font-size: 0.42em;
  font-weight: 600;
  line-height: 1.1;
  color: var(--dim);
  /* A little air between reading and base; without it the two collide at
     large sizes on a waveguide display. */
  transform: translateY(0.12em);
  -webkit-text-fill-color: currentColor;
}

/* Fallback renderer: an inline-block column per annotated segment, used when
   the webview does not stack <ruby> properly. Visually equivalent. */
.rgroup {
  display: inline-block;
  vertical-align: baseline;
  text-align: center;
  line-height: 1.05;
}

.rgroup .rtop {
  display: block;
  font-size: 0.42em;
  font-weight: 600;
  line-height: 1.1;
  color: var(--dim);
  margin-bottom: 0.04em;
}

.rgroup .rbase { display: block; }

/* Karaoke highlighting. Driven only by token start/end times. */
.tok.sung { color: var(--dim); }
.tok.sung rt, .tok.sung .rtop { color: var(--faint); }
.tok.active { color: var(--fg); }

.line-prev .clamp { -webkit-line-clamp: 1; }
.line-current .clamp { -webkit-line-clamp: 3; }
.line-next .clamp { -webkit-line-clamp: 2; }

.line.is-empty { display: none; }

/* --------------------------------------------------- special-state card */

.notice {
  grid-row: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

.notice-icon { font-size: 54px; line-height: 1; color: var(--dim); }
.notice-title { font-size: 38px; line-height: 1.15; color: var(--fg); }
.notice-body { font-size: 22px; line-height: 1.3; color: var(--faint); max-width: 460px; font-weight: 500; }

/* --------------------------------------------------------- pairing pad */

.pair {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.pair-title { font-size: 28px; color: var(--dim); }
.pair-digits { display: flex; gap: 12px; }

.pair-digit {
  width: 62px;
  height: 84px;
  border: 2px solid var(--faint);
  border-radius: 8px;
  font-size: 46px;
  line-height: 80px;
  text-align: center;
  color: var(--dim);
}

.pair-digit.active { border-color: var(--fg); color: var(--fg); }
.pair-hint { font-size: 18px; color: var(--faint); font-weight: 500; }

/* -------------------------------------------------------------- status */

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 19px;
  font-weight: 500;
  color: var(--faint);
  padding-bottom: 6px;
  white-space: nowrap;
}

.status-badges { color: var(--dim); }

.bar {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: 12px;
  height: 3px;
  background: #262626;
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill { height: 100%; width: 0%; background: var(--dim); }

/* Stale data (poll failures) dims the whole frame rather than hiding it. */
.stage.stale .lyrics, .stage.stale .meta { opacity: 0.35; }

@media (max-height: 480px) {
  :root { --pad: 16px; }
  .line-current { font-size: 46px; }
}
