/* Good Type, web. Mirrors the iPhone app: a full-bleed palette ground behind
   two specimen panes, and a plain light library beside or over it. */

:root {
  /* The library's own colours, from the app's Sheet palette. */
  --sheet-ground: #FCFCFB;
  --sheet-ink: #14161A;
  --sheet-muted: #6E7079;
  --sheet-faint: #A2A4AC;
  --sheet-line: #E5E5E2;
  --sheet-tint: #F1F1EE;

  /* The viewer's colours. app.js sets these from the chosen palette. */
  --ground: #FAF9F5;
  --heading-ink: #1C1B18;
  --body-ink: #1C1B18;

  --ui-font: "Helvetica Neue", Helvetica, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  --panel-width: 440px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--body-ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

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

button:focus-visible,
a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 6px;
}

svg.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.is-on svg.icon--fillable { fill: currentColor; }

/* ---------- Layout ---------- */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

/* On wide screens the library sits on the left, beside the viewer. */
@media (min-width: 1024px) {
  .app { grid-template-columns: var(--panel-width) 1fr; }
}

/* ---------- Viewer ---------- */

.viewer {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  transition: background-color 0.25s ease-out;
  min-width: 0;
}

.pane {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding-block: 20px;
  /* Wide screens keep the type to a readable column, still left-aligned. */
  padding-inline: max(24px, calc((100% - 880px) / 2));
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.pane--heading { color: var(--heading-ink); }
.pane--body { color: var(--body-ink); }

/* On touch screens the panes take swipes, so the page must not scroll under them. */
@media (pointer: coarse) {
  .pane { touch-action: none; }
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.label-row,
.name-row,
.weight-row {
  display: flex;
  align-items: center;
}

.label-row { justify-content: space-between; }

.label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.45;
}

.name {
  font-size: 15px;
  font-weight: 500;
  padding: 4px 6px;
  border-radius: 6px;
}

.name:hover { background: color-mix(in srgb, currentColor 9%, transparent); }

.weight-row span {
  font-size: 13px;
  opacity: 0.68;
  min-width: 64px;
  text-align: center;
}

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  opacity: 0.55;
  transition: opacity 0.15s, background-color 0.15s;
}

.icon-button:hover { opacity: 1; background: color-mix(in srgb, currentColor 9%, transparent); }
.icon-button.is-on { opacity: 1; }
.icon-button:disabled { opacity: 0.2; cursor: default; background: none; }

/* The rows sit flush with the type: pull the first button back by its own padding. */
.name-row,
.weight-row { margin-left: -8px; }

.specimen {
  margin: 0;
  transition: opacity 0.18s ease-out;
}

.specimen--heading {
  font-size: calc(clamp(34px, 3.4vw + 18px, 76px) * var(--scale, 1));
  line-height: 1.1;
  max-width: 16em;
  overflow-wrap: break-word;
}

.specimen--body {
  font-size: calc(clamp(17px, 0.35vw + 15.5px, 21px) * var(--scale, 1));
  line-height: 1.6;
  max-width: 38em;
}

/* ---------- Palette strip ---------- */

.strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 22px 2px;
  scrollbar-width: none;
}

.strip::-webkit-scrollbar { display: none; }
.strip[hidden] { display: none; }

.swatch {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.swatch span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--body-ink) 18%, transparent);
}

.swatch.is-on { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--body-ink) 85%, transparent); }

/* ---------- Control bar ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  color: var(--body-ink);
}

.bar__spacer { flex: 1; }

.square {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: color-mix(in srgb, var(--body-ink) 10%, transparent);
  transition: background-color 0.15s;
}

.square:hover { background: color-mix(in srgb, var(--body-ink) 16%, transparent); }

.square .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ground);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--body-ink) 35%, transparent);
}

.square.is-on .dot { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--body-ink) 90%, transparent); }

@media (min-width: 1024px) {
  .square--library { display: none; }
}

/* ---------- Library ---------- */

.library {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--sheet-ground);
  color: var(--sheet-ink);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.28s ease-out, visibility 0s linear 0.28s;
}

.library.is-open {
  transform: none;
  visibility: visible;
  transition: transform 0.28s ease-out;
}

@media (min-width: 1024px) {
  .library,
  .library.is-open {
    position: relative;
    inset: auto;
    z-index: auto;
    height: 100dvh;
    transform: none;
    visibility: visible;
    transition: none;
    order: -1;
    border-right: 1px solid var(--sheet-line);
  }

  .library .close { display: none; }
}

.library__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 18px 5vw 14px;
  border-bottom: 1px solid var(--sheet-line);
}

@media (min-width: 1024px) {
  .library__head { padding-inline: 22px; }
}

.library__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.library__count {
  font-size: 12px;
  color: var(--sheet-faint);
  flex: 1;
}

.close {
  align-self: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sheet-tint);
  display: grid;
  place-items: center;
}

.close svg.icon { width: 13px; height: 13px; stroke-width: 2.5; }

.library__body {
  overflow-y: auto;
  padding: 0 5vw 24px;
  container-type: inline-size;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 1024px) {
  .library__body { padding-inline: 22px; }
}

.library__foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 5vw calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--sheet-line);
}

@media (min-width: 1024px) {
  .library__foot { padding-inline: 22px; }
}

.foot-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* Segmented pills, as in the app. */
.pill {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 7px;
  background: var(--sheet-tint);
}

.pill--full { width: 100%; }
.pill--full .segment { flex: 1; }

.segment {
  height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--sheet-muted);
  white-space: nowrap;
}

.segment.is-on {
  background: var(--sheet-ground);
  color: var(--sheet-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 22, 26, 0.1);
}

.band-head {
  display: flex;
  justify-content: space-between;
  padding: 14px 8px 8px 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--sheet-faint);
  border-bottom: 1px solid var(--sheet-line);
}

.band-head--gap { margin-top: 18px; }

.empty--small {
  padding: 18px 8px;
  text-align: left;
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  border-left: 1px solid var(--sheet-line);
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  aspect-ratio: 3 / 2;
  padding: 0 5cqw;
  border-right: 1px solid var(--sheet-line);
  border-bottom: 1px solid var(--sheet-line);
  font-size: calc(5.2cqw * var(--scale, 1));
  line-height: 1.05;
  transition: background-color 0.12s;
}

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

.grid--one .cell {
  aspect-ratio: 4 / 1;
  font-size: calc(8.4cqw * var(--scale, 1));
}

.grid--amp .cell {
  aspect-ratio: 1 / 0.92;
  font-size: calc(20cqw * var(--scale, 1));
}

.cell.is-current {
  background: var(--sheet-ink);
  color: var(--sheet-ground);
}

.cell .heart {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--sheet-faint);
}

.cell .heart svg.icon { width: 11px; height: 11px; fill: currentColor; stroke: none; }
.cell.is-current .heart { color: color-mix(in srgb, var(--sheet-ground) 62%, transparent); }

/* Pair cards: picks and saved pairs, each on the ground it was chosen on. */
.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
}

.card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 20px 18px;
  border-radius: 12px;
}

.card__heading {
  display: block;
  font-size: calc(26px * var(--scale, 1));
  line-height: 1.15;
}

.card__body {
  display: block;
  margin-top: 6px;
  font-size: calc(16px * var(--scale, 1));
  opacity: 0.75;
}

.card__credit {
  display: block;
  margin-top: 14px;
  font-family: var(--ui-font);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  opacity: 0.68;
}

.card__credit a { color: inherit; }

.card__delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0.5;
}

.card__delete:hover { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
.card__delete svg.icon { width: 13px; height: 13px; }

.empty {
  padding: 64px 28px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: var(--sheet-muted);
}

/* ---------- Modals ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 22, 26, 0.32);
}

.modal[hidden] { display: none; }

.modal__card {
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--sheet-ground);
  color: var(--sheet-ink);
  border-radius: 16px 16px 0 0;
  padding: 22px 5vw calc(22px + env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
  .modal { align-items: center; padding: 24px; }
  .modal__card { max-width: 600px; border-radius: 16px; padding: 28px 30px; }
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal__title {
  margin: 0;
  font-size: calc(34px * var(--scale, 1));
  font-weight: 400;
  line-height: 1.1;
}

.modal__title--ui {
  font-family: var(--ui-font);
  font-size: 19px;
  font-weight: 600;
}

.modal__meta {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--sheet-muted);
}

.section-label {
  margin: 24px 0 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sheet-faint);
}

.chars {
  margin: 0;
  font-size: calc(21px * var(--scale, 1));
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.ramp {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ramp__row {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.ramp__label {
  flex: none;
  width: 72px;
  font-family: var(--ui-font);
  font-size: 11.5px;
  color: var(--sheet-muted);
}

.ramp__text {
  font-size: calc(23px * var(--scale, 1));
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paragraph {
  margin: 0;
  font-size: calc(16.5px * var(--scale, 1));
  line-height: 1.6;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}

.action {
  flex: 1 1 140px;
  height: 44px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  background: var(--sheet-ink);
  color: var(--sheet-ground);
}

.action--quiet {
  background: var(--sheet-tint);
  color: var(--sheet-ink);
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--sheet-muted);
  text-decoration: none;
}

.link:hover { color: var(--sheet-ink); }
.link svg.icon { width: 13px; height: 13px; }

.help-list {
  margin: 16px 0 0;
  padding-left: 18px;
  font-size: 14.5px;
  line-height: 1.55;
}

.help-list li + li { margin-top: 8px; }

.help-foot {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--sheet-line);
  font-size: 12.5px;
  color: var(--sheet-muted);
}

.help-foot a { color: var(--sheet-ink); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translate(-50%, 8px);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--sheet-ink);
  color: var(--sheet-ground);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-showing {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Centred on the viewer, not on the whole window, when the library sits beside it. */
@media (min-width: 1024px) {
  .toast { left: calc(var(--panel-width) + (100% - var(--panel-width)) / 2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
