/* Light Slides viewer — app-specific styles. Tokens and dialog chrome live
   in the vendored tokens.css / dialogs.css (copies of actions/design/ at
   the pinned tag). Pure HTML, CSS, and vanilla JavaScript. */

:root {
  --stage: #000;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3 {
  font-weight: 530;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
a {
  color: var(--link);
}
a:hover {
  color: var(--link-hover);
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--panel);
  color: var(--ink);
  padding: 0.5rem 1rem;
  z-index: 1001;
  border-radius: 0 0 var(--radius) 0;
}

.skip:focus-visible {
  left: 0;
}

.bar {
  padding: 1rem 0;
  box-shadow: inset 0 -0.5px 0 var(--hairline-strong);
}

/* Same centered 1200px grid as the viewer/decks below: the title sits
   over the viewer column, so the search stretches flush with the card
   grid's left edge and the pills end flush with its right. */
.bar-inner {
  display: grid;
  grid-template-columns: minmax(320px, 560px) 1fr;
  gap: 2rem;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.bar h1 {
  margin: 0;
  font-size: 1.1rem;
  white-space: nowrap;
}

.bar-inner > div:first-child {
  min-width: 0;
}

.sub {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 32vw;
}

.bar-side {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: flex-end;
  min-width: 0;
}

@media (max-width: 700px) {
  .bar {
    padding: 0.75rem 0;
  }
  .bar-inner {
    padding: 0 1rem;
    gap: 0.6rem;
  }
  .bar h1 {
    font-size: 1rem;
  }
  .sub {
    display: none;
  }
  .bar-side {
    gap: 0.5rem;
  }
  .bar-side .pill {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 560px) {
  /* One row still: the Textbook link drops out on narrow phones. */
  .bar-side a.pill {
    display: none;
  }
  #search {
    font-size: 0.85rem;
  }
  .lib-hint {
    display: none;
  }
}

#search {
  background: var(--panel);
  color: var(--ink);
  border: none;
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  min-width: 0;
  flex: 1 1 auto;
  font: inherit;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 560px) 1fr;
  gap: 2rem;
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.viewer {
  position: sticky;
  top: 1rem;
  align-self: start;
}

.stage {
  background: var(--stage);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 0.5px var(--hairline-strong),
    0 0 0 10px var(--panel),
    0 0 0 10.5px var(--hairline);
  overflow: hidden;
  aspect-ratio: 1;
  margin: 10.5px;
}

.stage video {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--stage);
  object-fit: cover;
  cursor: pointer;
}

.video-fallback {
  margin: 0.75rem 0 0;
  padding: 0.7rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--panel);
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
  border-radius: var(--radius);
}

.video-fallback[hidden] {
  display: none;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

#play {
  background: var(--panel);
  color: var(--ink);
  border: none;
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  font-size: 1rem;
  touch-action: manipulation;
}

#scrub {
  flex: 1;
  accent-color: var(--link);
  cursor: ew-resize;
  touch-action: manipulation;
}
.time {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.empty {
  color: var(--muted);
  padding: 1rem 0;
}

.caption {
  min-height: 4.4em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.05rem;
  background: var(--panel);
  box-shadow: inset 0 0 0 0.5px var(--hairline);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin: 0 0 1.4rem;
  text-wrap: balance;
}

.caption .w {
  color: var(--muted);
  margin-right: 0.3em;
}

.caption .w:last-child {
  margin-right: 0;
}

.caption .w.said {
  color: var(--ink);
}

.dark-mode .caption .w.said {
  font-weight: 700;
}

/* Light-mode karaoke: upcoming words sit back in dark gray, spoken words
   go black and bold. (Bold reflows the line a touch as words light up;
   the alternative faux-bold was tried and judged too faint.) */
html:not(.dark-mode) .caption .w {
  color: #555;
}

html:not(.dark-mode) .caption .w.said {
  color: #000;
  font-weight: 700;
}

.decks {
  min-width: 0;
}

.deck h2 {
  font-size: 0.8125rem;
  font-weight: 500;
  margin: 1.2rem 0 0.5rem;
  color: var(--muted);
  text-transform: none;
}

.deck h2:first-child {
  margin-top: 0;
}

.row {
  display: flex;
  gap: 0.9rem;
  overflow-x: auto;
  padding: 0.9rem 0.2rem 1.1rem 0.6rem;
  scroll-snap-type: x mandatory;
}

.card {
  scroll-snap-align: start;
  flex: 0 0 132px;
  background: var(--panel);
  border: none;
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
  border-radius: var(--radius);
  transition: transform 0.15s ease;
  touch-action: manipulation;
}

.card:hover {
  transform: translateY(-3px);
}
.card[aria-current="true"] {
  box-shadow: inset 0 0 0 1.5px var(--link);
}

.card-poster {
  display: block;
  width: 100%;
  background: var(--stage);
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

.card-poster img {
  /* Fixed square thumbs: uniform images drive uniform cards. The whole
     frame stays visible, centered on black with even margins. */
  width: 132px;
  height: 132px;
  object-fit: contain;
  object-position: center;
  display: block;
  margin: 0 auto;
  background: var(--stage);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.4rem 0.6rem 0.6rem;
}

.card-name {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: inherit;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-name:hover {
  color: var(--link);
}

.card-yt {
  flex: none;
  display: flex;
  padding: 0.35rem;
  border-radius: 50%;
  color: var(--muted);
}

.card-yt:hover {
  color: var(--link);
}

.card-yt svg {
  display: block;
}

/* Mineral library popup: docks right, covers the decks, leaves the ocular visible. */
.library {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(740px, 96vw);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  background: var(--bg);
  box-shadow: -8px 0 24px rgb(0 0 0 / 0.18);
}

.library[hidden] {
  display: none;
}

.lib-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  box-shadow: inset 0 -0.5px 0 var(--hairline-strong);
}

.lib-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.lib-seg {
  /* Right edge sits flush with the tab column's right edge: the head's
     0.9rem left padding is subtracted from the 224px tab width, and the
     search fills the body column. */
  flex: 0 0 calc(224px - 0.9rem);
  display: flex;
  background: var(--panel);
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.lib-seg button {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex: 1;
  text-align: center;
}

.lib-seg button[aria-pressed="true"] {
  background: var(--bg);
  color: var(--ink);
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
}

.lib-seg button:hover {
  color: var(--ink);
}

#libSearch {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  color: var(--ink);
  border: none;
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
  border-radius: var(--radius);
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.9rem;
}

.lib-hint {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.lib-main {
  flex: 1;
  min-height: 0;
  display: flex;
}

.lib-tabs {
  flex: 0 0 224px;
  overflow-y: auto;
  padding: 0.6rem 0 1rem;
  box-shadow: inset -0.5px 0 0 var(--hairline-strong);
}

.lib-tab {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.4rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  overflow-wrap: break-word;
}

.lib-tab:hover {
  color: var(--ink);
}

.lib-tab[aria-selected="true"] {
  color: var(--link);
  box-shadow: inset 2px 0 0 var(--link);
}

.lib-body {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 1rem 1.5rem 1.5rem;
}

.lib-body h2 {
  margin: 0;
  font-size: 1.25rem;
}

.lib-flag {
  display: inline-block;
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--panel);
  box-shadow: inset 0 0 0 0.5px var(--hairline-strong);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  cursor: help;
}

.lib-tab--missing {
  font-style: italic;
}

.lib-formula {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.lib-facts {
  margin: 1rem 0 0;
  display: grid;
  gap: 0.55rem;
}

.lib-facts > div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.75rem;
}

.lib-facts dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.lib-facts dd {
  margin: 0;
}

.lib-minerals {
  margin: 0.25rem 0 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.lib-mineral-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--link);
  cursor: pointer;
  text-align: left;
}

.lib-mineral-link:hover {
  color: var(--link-hover);
}

.lib-mineral-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.lib-body h3 {
  margin: 1.25rem 0 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.lib-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

@media (max-width: 860px) {
  .bar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }
  .library {
    left: 0;
    width: auto;
  }
  .lib-seg {
    flex-basis: calc(128px - 0.9rem);
  }
  .lib-tabs {
    flex-basis: 128px;
  }
  .lib-facts > div {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .viewer {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card:hover {
    transform: none;
    transition: none;
  }
}
