/*
 * Enova WP — encyclopedia components (ency-*).
 *
 * Rebuilt for WordPress from the block reference (enova-encyclopedia-blocks.md)
 * that went with the Ghost theme's encyclopedia.css (v1.10.3). The markup is
 * identical, so pasted/imported blocks and the [enova_*] shortcodes share
 * these styles.
 *
 * Built only from Enova's tokens: grey scale, accent (--ghost-accent-color /
 * --brand-readable), Lora headings, Inter body, post-card hover physics.
 * Dark mode follows the theme's `.dark` class. Loaded as a plain file outside
 * the Vite build (like gallery-extended.css), only on pages that use it.
 *
 * Selectors are prefixed with .gh-content where needed to beat the prose
 * plugin's link/table/figure/img defaults.
 */

:root {
  --ency-surface: #fff;
  --ency-surface-2: var(--color-grey-50, #fafafa);
  --ency-border: var(--color-grey-200, #e4e4e7);
  --ency-border-hover: var(--color-grey-300, #d4d4d8);
  --ency-text: var(--color-grey-900, #09090b);
  --ency-muted: var(--color-grey-500, #71717a);
  --ency-soft: var(--color-grey-600, #52525b);
  --ency-accent: var(--ghost-accent-color, #ff6b6b);
  --ency-accent-text: var(--brand-readable, var(--ency-accent));
  --ency-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --ency-shadow-hover: 0 20px 25px -5px rgb(228 228 231 / 0.5), 0 8px 10px -6px rgb(228 228 231 / 0.5);
  --ency-radius: 0.75rem;
  --ency-heading: var(--font-heading, "Lora Variable", "Lora", Georgia, serif);
  --ency-body: var(--font-sans, "Inter Variable", "Inter", system-ui, sans-serif);
}

.dark {
  --ency-surface: var(--color-grey-800, #18181b);
  --ency-surface-2: color-mix(in srgb, var(--color-grey-800, #18181b) 60%, var(--color-grey-900, #09090b));
  --ency-border: var(--color-grey-700, #27272a);
  --ency-border-hover: var(--color-grey-600, #52525b);
  --ency-text: #fff;
  --ency-muted: var(--color-grey-400, #a1a1aa);
  --ency-soft: var(--color-grey-300, #d4d4d8);
  --ency-shadow-hover: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
}

/* ------------------------------------------------------------------
 * Shared resets inside the prose column
 * ------------------------------------------------------------------ */
.gh-content :is(.ency-world-card, .ency-cat-tile, .ency-story-row),
.gh-content :is(.ency-world-card, .ency-cat-tile, .ency-story-row):hover {
  text-decoration: none;
  color: inherit;
}
.gh-content [class^="ency-"] :is(h3, p, figure, img) { margin: 0; }
.gh-content .ency-world-card figure,
.gh-content .ency-world-card img { border-radius: 0; box-shadow: none; }

/* ------------------------------------------------------------------
 * Block 7 — section label
 * ------------------------------------------------------------------ */
.ency-section-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2.5rem 0 1rem;
  font-family: var(--ency-body);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ency-muted);
}
.ency-section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ency-border);
}

/* ------------------------------------------------------------------
 * Block 1 — world card grid
 * ------------------------------------------------------------------ */
.ency-world-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin: 1.5rem 0 2.5rem;
}
@container (min-width: 30rem) { .ency-world-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 56rem) { .ency-world-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.ency-world-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ency-surface);
  border: 1px solid var(--ency-border);
  border-radius: var(--ency-radius);
  box-shadow: var(--ency-shadow);
  transition: transform 300ms ease-out, box-shadow 300ms ease-out, border-color 300ms ease-out;
}
.ency-world-card:hover {
  transform: translateY(-0.25rem);
  box-shadow: var(--ency-shadow-hover);
  border-color: var(--ency-border-hover);
}
.ency-world-card:focus-visible { outline: 2px solid var(--ency-accent); outline-offset: 2px; }

.ency-world-card figure {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--ency-surface-2);
}
.ency-world-card figure::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06);
  pointer-events: none;
}
.ency-world-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms ease-out;
}
.ency-world-card:hover img { transform: scale(1.03); }

.ency-body {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1.125rem 1.25rem 1.25rem;
  flex: 1;
}
.ency-world-card h3 {
  font-family: var(--ency-heading);
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ency-text);
  transition: color 200ms;
}
.ency-world-card:hover h3 { color: var(--ency-accent-text); }
.ency-genre {
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--ency-muted);
}
.ency-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: auto;
  padding-top: 0.625rem;
}
.ency-stats span {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  background: var(--ency-surface-2);
  border: 1px solid var(--ency-border);
  color: var(--ency-soft);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------
 * Blocks 2 & 3 — category tiles
 * ------------------------------------------------------------------ */
.ency-cat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 2.5rem;
}
@container (min-width: 36rem) { .ency-cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (min-width: 56rem) { .ency-cat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.ency-cat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.25rem;
  padding: 1rem 1.125rem;
  background: var(--ency-surface);
  border: 1px solid var(--ency-border);
  border-radius: var(--ency-radius);
  box-shadow: var(--ency-shadow);
  transition: transform 300ms ease-out, box-shadow 300ms ease-out, border-color 300ms ease-out;
}
.ency-cat-tile:hover {
  transform: translateY(-0.125rem);
  box-shadow: var(--ency-shadow-hover);
  border-color: var(--ency-accent);
}
.ency-cat-tile:focus-visible { outline: 2px solid var(--ency-accent); outline-offset: 2px; }

.ency-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.5rem;
  border-radius: 0.5rem;
  color: var(--ency-accent-text);
  background: color-mix(in srgb, var(--ency-accent) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ency-accent) 18%, transparent);
  transition: background-color 200ms, color 200ms;
}
.ency-icon svg { width: 1.125rem; height: 1.125rem; }
.ency-cat-tile:hover .ency-icon { background: var(--ency-accent); color: var(--brand-contrast, #fff); }

.ency-label {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ency-text);
}
.ency-count {
  font-size: 0.75rem;
  color: var(--ency-muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------
 * Block 4 — access legend
 * ------------------------------------------------------------------ */
.ency-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1.25rem 0 2rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--ency-soft);
  background: var(--ency-surface-2);
  border: 1px solid var(--ency-border);
  border-radius: var(--ency-radius);
}
.ency-legend > span { display: inline-flex; align-items: center; gap: 0.5rem; }
.ency-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.ency-dot-free { background: var(--color-grey-400, #a1a1aa); }
.ency-dot-scholar { background: var(--ency-accent); }
.ency-dot-keeper {
  background: var(--color-grey-900, #09090b);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ency-accent) 45%, transparent);
}
.dark .ency-dot-keeper { background: #fff; }

/* ------------------------------------------------------------------
 * Block 5 — quick-reference panel (infobox)
 * ------------------------------------------------------------------ */
.ency-infobox {
  margin: 0 0 2rem;
  overflow: hidden;
  background: var(--ency-surface);
  border: 1px solid var(--ency-border);
  border-top: 3px solid var(--ency-accent);
  border-radius: var(--ency-radius);
  box-shadow: var(--ency-shadow);
}
.gh-content .ency-infobox table {
  display: table;
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.5;
  table-layout: auto;
}
.gh-content .ency-infobox tr { border: 0; }
.gh-content .ency-infobox tr + tr td { border-top: 1px solid var(--ency-border); }
.gh-content .ency-infobox td {
  padding: 0.625rem 1rem;
  vertical-align: top;
  border: 0;
  color: var(--ency-text);
}
.gh-content .ency-infobox td:first-child {
  width: 34%;
  padding-inline-end: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ency-muted);
  background: var(--ency-surface-2);
  white-space: nowrap;
}
.gh-content .ency-infobox a {
  color: var(--ency-accent-text);
  text-decoration: none;
  font-weight: 600;
}
.gh-content .ency-infobox a:hover { text-decoration: underline; text-underline-offset: 2px; }
@container (max-width: 26rem) {
  .gh-content .ency-infobox td:first-child { white-space: normal; width: 40%; }
}

/* ------------------------------------------------------------------
 * Block 6 — story list
 * ------------------------------------------------------------------ */
.ency-story-list {
  display: flex;
  flex-direction: column;
  margin: 1.25rem 0 2.5rem;
  background: var(--ency-surface);
  border: 1px solid var(--ency-border);
  border-radius: var(--ency-radius);
  box-shadow: var(--ency-shadow);
  overflow: hidden;
}
.ency-story-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  transition: background-color 200ms;
}
.ency-story-row + .ency-story-row { border-top: 1px solid var(--ency-border); }
.ency-story-row:hover { background: var(--ency-surface-2); }
.ency-story-row:focus-visible { outline: 2px solid var(--ency-accent); outline-offset: -2px; }
.gh-content .ency-story-row br { display: none; }
.ency-story-title {
  display: block;
  font-family: var(--ency-heading);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ency-text);
  transition: color 200ms;
}
.ency-story-row:hover .ency-story-title { color: var(--ency-accent-text); }
.ency-story-sub {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ency-muted);
}

.ency-badge {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  color: var(--ency-soft);
  background: var(--ency-surface-2);
  border: 1px solid var(--ency-border);
  white-space: nowrap;
}
.ency-badge-brand {
  color: var(--ency-accent-text);
  background: color-mix(in srgb, var(--ency-accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--ency-accent) 25%, transparent);
}

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