/* Reading library card contract
 *
 * This route-specific layer is loaded before the shared visual system; its
 * three Reading catalog renderers can share one compact, predictable rhythm
 * without changing unrelated library cards.
 */

:root {
  --reading-card-ink: #1b2945;
  --reading-card-muted: #6a7488;
  --reading-card-line: #e3e6ef;
  --reading-card-premium: #7772d8;
  --reading-card-premium-soft: rgba(119, 114, 216, .13);
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card {
  position: relative;
  display: flex;
  min-width: 0;
  height: 132px;
  min-height: 132px;
  box-sizing: border-box;
  flex-direction: column;
  padding: 14px 16px;
  overflow: hidden;
  border: 1px solid var(--reading-card-line);
  border-radius: 16px;
  background: #fff;
  color: var(--reading-card-ink);
  box-shadow: 0 3px 12px rgba(40, 42, 77, .045);
  text-decoration: none;
  transition: transform 160ms cubic-bezier(.23, 1, .32, 1), border-color 180ms ease,
    box-shadow 180ms cubic-bezier(.23, 1, .32, 1), background-color 180ms ease;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card:active {
  transform: scale(.985);
}

@media (hover: hover) and (pointer: fine) {
  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card:hover {
    transform: translateY(-2px);
    border-color: #c9cfdd;
    box-shadow: 0 11px 24px rgba(53, 55, 105, .09);
  }

  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card.is-premium:hover {
    border-color: #625dbf;
    box-shadow: inset 0 0 0 1px rgba(119, 114, 216, .18),
      0 11px 24px rgba(79, 75, 169, .12);
  }
}

/* Premium identity is independent from the effective lock state. Members see
 * the same restrained outline as non-members, while only locked cards expose
 * the tiny lock glyph. The surface stays white in both cases. */
body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card.reading-card.is-premium {
  border: 1.5px solid var(--reading-card-premium);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--reading-card-premium-soft),
    0 3px 12px rgba(40, 42, 77, .045);
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card.is-locked {
  cursor: not-allowed;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card.is-access-pending {
  cursor: progress;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-meta {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 18px;
  box-sizing: border-box;
  grid-template-columns: auto minmax(0, 1fr) 14px 14px;
  align-items: center;
  column-gap: 6px;
  margin: 0 0 7px;
  color: var(--reading-card-muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 18px;
  letter-spacing: .008em;
  font-variant-numeric: tabular-nums;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-index {
  min-width: max-content;
  color: #667187;
  white-space: nowrap;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-context {
  min-width: 0;
  overflow: hidden;
  color: #7a8497;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-title {
  display: -webkit-box;
  min-width: 0;
  min-height: 46px;
  margin: 0;
  overflow: hidden;
  color: var(--reading-card-ink);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.006em;
  font-optical-sizing: auto;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-divider {
  width: 100%;
  height: 1px;
  flex: 0 0 1px;
  margin-top: 6px;
  background: var(--reading-card-line);
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-foot {
  min-height: 18px;
  margin: 6px 0 0;
  padding: 0;
  border: 0;
  color: var(--reading-card-muted);
  font-size: 13px;
  font-weight: 550;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Completed Reading cards reuse the existing footer row for the two explicit
 * actions. The wrapper keeps the same 132/126px contract as every untouched
 * Reading card; no completion-only row is allowed to change its height. */
body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card.has-ctw-actions .reading-card-main {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  cursor: default;
  color: inherit;
  text-decoration: none;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-action-foot {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-actions {
  display: inline-flex;
  min-width: max-content;
  align-items: center;
  gap: 10px;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-action {
  position: relative;
  color: #5752b7;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-decoration: none;
  white-space: nowrap;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-action::before {
  position: absolute;
  inset: -13px -4px;
  content: '';
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-action:focus-visible {
  border-radius: 4px;
  outline: 2px solid #5752b7;
  outline-offset: 2px;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-history-note {
  max-width: 132px;
  overflow: hidden;
  color: #7a8497;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-frequency,
body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-lock {
  display: block;
  box-sizing: border-box;
  justify-self: end;
  opacity: 0;
  pointer-events: none;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-frequency {
  width: 14px;
  height: 14px;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-lock {
  width: 18px;
  height: 18px;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-frequency.is-visible {
  opacity: .62;
  color: #6964c4;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
  filter: saturate(.7);
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-lock.is-visible {
  position: relative;
  border: 2px solid #5b55c4;
  border-radius: 4px;
  background: #f5f4ff;
  box-shadow: 0 0 0 3px rgba(91, 85, 196, .1);
  opacity: 1;
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-lock.is-visible::before {
  position: absolute;
  top: -8px;
  left: 2px;
  width: 10px;
  height: 9px;
  box-sizing: border-box;
  border: 2px solid #5b55c4;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  content: '';
}

body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-lock.is-visible::after {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 3px;
  height: 5px;
  border-radius: 2px;
  background: #5b55c4;
  content: '';
}

@media (max-width: 900px) {
  body :is(.reading-hub, .reading-card-shell) .reading-list-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  body :is(.reading-hub, .reading-card-shell) .reading-list-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card {
    height: 126px;
    min-height: 126px;
    padding: 13px 14px;
    border-radius: 15px;
  }

  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-title {
    min-height: 43px;
    font-size: 16px;
    line-height: 1.35;
  }

  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-meta {
    margin-bottom: 6px;
  }

  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card-foot {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card,
  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card:hover,
  body :is(.reading-hub, .reading-card-shell) .reading-list-grid .reading-card:active {
    transform: none;
    transition-duration: 1ms;
  }
}
