/* ==========================================================================
   Waidrn v3 — realm tiles (V3-06b, #574) — art lane stylesheet
   ==========================================================================
   Scoped to the tile components only (.v3-realm-grid / .v3-realm-list /
   .v3-realm-card / .v3-realm-row). Nothing here touches legacy v2 pages.

   Design source: mockups/v3 realm directory renders + mockups/v3/_tokens.css.
   Geometry is token-driven so the design lane (#543/#544) can re-theme:
     --v3-tile-radius, --v3-card-min, --v3-cover-aspect, --v3-row-cover-w,
     --v3-gap.
   ========================================================================== */

.v3-realm-grid,
.v3-realm-list,
.v3-realm-card,
.v3-realm-row,
.v3-folder-grid,
.v3-realm-folder {
  --v3-bg: var(--bg, #0a0b0c);
  --v3-panel: var(--panel, #101317);
  --v3-panel-2: var(--panel-2, #14181d);
  --v3-line: var(--line, #232a33);
  --v3-line-2: var(--line-2, #303944);
  --v3-ink: var(--ink, #ecf0f4);
  --v3-ink-2: var(--ink-2, #c3cbd5);
  --v3-ink-3: var(--ink-3, #8d98a5);
  --v3-gold: var(--gold, #e8c987);
  --v3-gold-line: var(--gold-line, #4a3f22);
  --v3-font-ui: var(--font-ui, "Inter", system-ui, -apple-system, "Segoe UI", sans-serif);
  --v3-font-mono: var(--font-mono, "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace);
  --v3-tile-radius: 10px;
  --v3-card-min: 244px;
  --v3-cover-aspect: 16 / 9;
  --v3-row-cover-w: 88px;
  --v3-row-cover-aspect: 16 / 10;
  --v3-folder-min: 120px;
  --v3-folder-radius: 8px;
  --v3-gap: 14px;

  font-family: var(--v3-font-ui);
  color: var(--v3-ink);
}

/* --- shared cover frame (generated fallback + uploads) ------------------- */
.v3-tile-cover {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: calc(var(--v3-tile-radius) - 2px);
  background: #05070a;
  --v3-hue-accent: #3a4450;
}
.v3-tile-cover--generated {
  box-shadow: inset 0 0 0 1px var(--v3-hue-accent);
}
.v3-tile-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* hue accents (0..7) — generated art keeps a stable identity colour */
.v3-tile-cover[data-hue="0"] { --v3-hue-accent: #8fc9bf; }
.v3-tile-cover[data-hue="1"] { --v3-hue-accent: #e8c987; }
.v3-tile-cover[data-hue="2"] { --v3-hue-accent: #e08d61; }
.v3-tile-cover[data-hue="3"] { --v3-hue-accent: #a9b8ff; }
.v3-tile-cover[data-hue="4"] { --v3-hue-accent: #86c9a9; }
.v3-tile-cover[data-hue="5"] { --v3-hue-accent: #9fd6b8; }
.v3-tile-cover[data-hue="6"] { --v3-hue-accent: #9fb4c8; }
.v3-tile-cover[data-hue="7"] { --v3-hue-accent: #c49a55; }

/* --- a) explorer grid: cover-forward cards ------------------------------ */
.v3-realm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--v3-card-min), 1fr));
  gap: var(--v3-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}
.v3-realm-grid > li { display: flex; }

.v3-realm-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-tile-radius);
  background: var(--v3-panel);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}
.v3-realm-card .v3-tile-cover {
  aspect-ratio: var(--v3-cover-aspect);
  border-radius: 0;
}
.v3-realm-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 12px;
}
.v3-realm-card-title { font-size: 13.5px; font-weight: 650; line-height: 1.25; color: var(--v3-ink); }
.v3-realm-card-path {
  font-family: var(--v3-font-mono);
  font-size: 11px;
  color: var(--v3-ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.v3-realm-card:hover { border-color: var(--v3-line-2); background: var(--v3-panel-2); }
.v3-realm-card.is-current { border-color: var(--v3-gold-line); box-shadow: inset 0 0 0 1px var(--v3-gold-line); }

/* --- directory rows ----------------------------------------------------- */
.v3-realm-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.v3-realm-list > li { display: flex; }

.v3-realm-row {
  display: grid;
  grid-template-columns: var(--v3-row-cover-w) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-tile-radius);
  background: var(--v3-panel);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}
.v3-realm-row .v3-tile-cover { width: var(--v3-row-cover-w); aspect-ratio: var(--v3-row-cover-aspect); }
.v3-realm-row-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.v3-realm-row-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.v3-realm-row-title { font-size: 13.5px; font-weight: 650; color: var(--v3-ink); white-space: nowrap; }
.v3-realm-row-path {
  font-family: var(--v3-font-mono); font-size: 10.5px; color: var(--v3-ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.v3-realm-row-desc {
  font-size: 11.5px; line-height: 1.35; color: var(--v3-ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.v3-realm-row:hover { border-color: var(--v3-line-2); background: var(--v3-panel-2); }
.v3-realm-row.is-current { border-color: var(--v3-gold-line); }

/* --- kind chips --------------------------------------------------------- */
.v3-tile-kinds { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 0; padding: 0; list-style: none; }
.v3-tile-kind {
  padding: 1px 7px;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-bg);
  color: var(--v3-ink-3);
  font-size: 10px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* --- power / likes ------------------------------------------------------ */
.v3-tile-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  margin: 0;
  font-family: var(--v3-font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--v3-ink-2);
  white-space: nowrap;
}
.v3-tile-stat-label {
  margin-right: 5px;
  font-family: var(--v3-font-ui);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--v3-ink-3);
}
.v3-tile-power { color: var(--v3-gold); }
.v3-realm-card .v3-tile-stats {
  flex-direction: row;
  gap: 12px;
  align-items: baseline;
  padding-top: 6px;
  border-top: 1px solid var(--v3-line);
  margin-top: 4px;
}

/* --- a) band: compact folder-style grid (#646 operator clarification) ----
   Small square cover thumb, one-line truncated title and a tiny kind/power
   badge. Folder-like density, not the large cover-forward card. */
.v3-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--v3-folder-min), 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.v3-folder-grid > li { display: flex; min-width: 0; }

.v3-realm-folder {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  padding: 5px 5px 4px;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-folder-radius);
  background: var(--v3-panel);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}
.v3-realm-folder .v3-tile-cover {
  aspect-ratio: 1 / 1;
  border-radius: calc(var(--v3-folder-radius) - 2px);
}
.v3-realm-folder-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 4px 2px 0;
}
.v3-realm-folder-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--v3-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v3-realm-folder-badge {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-family: var(--v3-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  color: var(--v3-ink-3);
  white-space: nowrap;
  overflow: hidden;
}
.v3-realm-folder-kind { text-transform: uppercase; }
.v3-realm-folder-power { color: var(--v3-gold); }
.v3-realm-folder:hover {
  border-color: var(--v3-line-2);
  background: var(--v3-panel-2);
  transform: translateY(-1px);
}
.v3-realm-folder:hover .v3-realm-folder-title { color: var(--v3-gold); }
.v3-realm-folder.is-current {
  border-color: var(--v3-gold-line);
  box-shadow: inset 0 0 0 1px var(--v3-gold-line);
}


.v3-realm-card:focus-visible,
.v3-realm-row:focus-visible,
.v3-realm-folder:focus-visible { outline: 2px solid var(--v3-gold); outline-offset: 2px; }

/* --- responsive: phone 390 ---------------------------------------------- */
@media (max-width: 720px) {
  .v3-realm-grid { grid-template-columns: 1fr; --v3-card-min: 0; }
  /* Folder tiles stay compact on phones: 2–3 columns at 360–390. */
  .v3-folder-grid { --v3-folder-min: 104px; gap: 8px; }
  .v3-realm-row {
    grid-template-columns: 64px minmax(0, 1fr);
    --v3-row-cover-w: 64px;
    row-gap: 6px;
  }
  .v3-realm-row .v3-tile-stats {
    grid-column: 2;
    flex-direction: row;
    gap: 12px;
    align-items: baseline;
    justify-self: start;
  }
  .v3-realm-row-desc {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

/* --- motion / contrast / forced-colors ---------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .v3-realm-card, .v3-realm-row, .v3-realm-folder { transition: none; }
  .v3-realm-folder:hover { transform: none; }
}
@media (prefers-contrast: more) {
  .v3-realm-card, .v3-realm-row, .v3-realm-folder { border-color: var(--v3-line-2); }
  .v3-tile-kind { border-color: var(--v3-ink-3); color: var(--v3-ink-2); }
}
@media (forced-colors: active) {
  .v3-realm-card, .v3-realm-row, .v3-realm-folder { border: 1px solid ButtonText; }
  .v3-tile-cover { forced-color-adjust: none; }
}

/* --- a) band centre (>=901px): folder-like 2–6 column density ------------ */
@media (min-width: 901px) {
  /* Folder-like density inside the band centre: 2–6 columns across 901–1440. */
  .v3-folder-grid { --v3-folder-min: 132px; gap: 9px; }
}
@media (min-width: 901px) and (max-width: 1179px) {
  .v3-folder-grid { --v3-folder-min: 112px; }
}

/* --- specimen page (evidence renderer only; not part of the site) ------- */
.v3-art-specimen {
  background: var(--v3-bg, #0a0b0c);
  color: var(--v3-ink, #ecf0f4);
  font-family: var(--v3-font-ui, system-ui, sans-serif);
  margin: 0;
}
.v3-art-specimen-main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; }
.v3-art-specimen-main h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; color: var(--v3-gold, #e8c987); }
.v3-art-specimen-note { margin: 0 0 24px; font-size: 12.5px; line-height: 1.5; color: var(--v3-ink-2, #c3cbd5); }
.v3-art-specimen-main section { margin: 0 0 28px; }
.v3-art-specimen-main h2 {
  margin: 0 0 10px; font-size: 13px; font-weight: 650; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--v3-ink-3, #8d98a5);
}

/* ==========================================================================
   Operator corrections (#663): title on cover, no Division label, hover card.
   ========================================================================== */
.v3-realm-folder { position: relative; }
.v3-realm-folder .v3-tile-cover { position: relative; }
.v3-realm-folder-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 7px 6px;
  background: linear-gradient(180deg, transparent, rgba(4, 6, 10, .88));
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v3-realm-folder-power {
  position: absolute;
  top: 5px;
  right: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(4, 6, 10, .72);
  font-family: var(--v3-font-mono);
  font-size: 8.5px;
  color: var(--v3-gold);
}
.v3-realm-folder-hover {
  display: none;
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: calc(100% + 6px);
  z-index: 40;
  padding: 8px 9px;
  border: 1px solid var(--v3-line-2);
  border-radius: 7px;
  background: var(--v3-panel-2);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
  pointer-events: none;
}
.v3-realm-folder:hover .v3-realm-folder-hover,
.v3-realm-folder:focus-visible .v3-realm-folder-hover { display: block; }
.v3-realm-folder-hover strong { display: block; font-size: 11px; color: var(--v3-ink); }
.v3-realm-folder-hover-desc { display: block; margin-top: 3px; font-size: 9.5px; line-height: 1.35; color: var(--v3-ink-2); }
.v3-realm-folder-hover-kinds { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.v3-realm-folder-hover-kinds span { padding: 0 5px; border: 1px solid var(--v3-line); border-radius: 999px; font-size: 8px; color: var(--v3-ink-3); }
.v3-realm-folder-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1px 6px;
  padding: 4px 2px 0;
  font-size: 8.5px;
  line-height: 1.3;
  color: var(--v3-ink-3);
}

/* Stage proposal: realm covers fill the tile; title and counts sit on cover. */
.v3-realm-folder { position: relative; padding: 0; overflow: hidden; }
.v3-realm-folder .v3-tile-cover { aspect-ratio: 1 / 1.08; border-radius: var(--v3-folder-radius); }
/* The title's own gradient is the scrim for the whole label: it runs from
   above the title down to the tile's edge, so neither the title nor the count
   underneath sits on bare cover art. Names wrap to two lines instead of being
   cut off ("Salt Marsh Read…"), which keeps them whole on narrower tiles. */
.v3-realm-folder-title {
  bottom: 0;
  padding: 30px 8px 25px;
  background: linear-gradient(180deg, transparent 0, rgba(4, 6, 10, .64) 48%, rgba(4, 6, 10, .88) 100%);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.v3-realm-folder-meta {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 7px;
  z-index: 2;
  padding: 0;
  color: rgba(236, 240, 244, .78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
}
.v3-realm-folder:hover .v3-realm-folder-title { color: #fff; }
