/* Compact living index — intentionally isolated from the read-along card pages. */

html:has(.living-index-page) {
  height: 100%;
  overflow: hidden;
}

.living-index-page {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.living-index-page .atlas-header {
  position: relative;
  z-index: 30;
  width: 100%;
  min-height: 64px;
  padding-inline: clamp(18px, 3vw, 42px);
  background: rgba(251, 250, 246, 0.96);
  backdrop-filter: blur(12px);
}

.living-index-page .index-shell {
  display: grid;
  width: 100%;
  max-width: none;
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  min-height: 0;
  margin: 0;
  grid-template-columns: minmax(250px, 0.78fr) minmax(430px, 1.62fr) minmax(250px, 0.8fr);
  overflow: hidden;
}

.index-controls,
.index-preview,
.index-catalog {
  min-width: 0;
  min-height: 0;
}

.index-controls {
  display: flex;
  flex-direction: column;
  padding: clamp(24px, 3vw, 42px);
  overflow-y: auto;
  border-right: 1px solid var(--ink);
  background: #edf3ef;
}

.index-identity .eyebrow {
  color: var(--green);
}

.index-identity h1 {
  max-width: 7ch;
  margin: 13px 0 0;
  font-family: var(--display);
  font-size: clamp(3.25rem, 5.2vw, 5.8rem);
  font-weight: 520;
  letter-spacing: -0.068em;
  line-height: 0.86;
}

.index-identity > p:last-child {
  max-width: 34ch;
  margin: 22px 0 0;
  font-family: var(--reading);
  font-size: 0.98rem;
  line-height: 1.48;
}

.directory-search {
  margin-top: auto;
  padding-top: 30px;
}

.directory-search label,
.directory-filter-block > p {
  display: block;
  margin: 0 0 8px;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1.3;
  text-transform: uppercase;
}

.search-field {
  position: relative;
}

.search-field input {
  width: 100%;
  height: 50px;
  padding: 0 44px 0 13px;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: rgba(251, 250, 246, 0.78);
  font-size: 0.96rem;
  font-weight: 650;
  appearance: none;
}

.search-field input::placeholder {
  color: var(--muted);
  opacity: 0.78;
}

.search-field kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 800;
  transform: translateY(-50%);
}

.directory-filter-block {
  margin-top: 22px;
}

.directory-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.directory-filters button,
.directory-actions button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  line-height: 1.2;
  text-transform: uppercase;
}

.directory-filters button[aria-pressed="true"] {
  color: var(--paper);
  background: var(--ink);
}

.directory-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: 13px;
}

.directory-actions #unlistenedToggle[aria-pressed="true"] {
  color: var(--paper);
  background: var(--green);
}

.directory-actions #randomCard {
  background: #f4b9d0;
}

.directory-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.directory-context {
  min-height: 2.6em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.directory-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 20px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.directory-progress p {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.directory-progress strong {
  font-size: 0.88rem;
  font-weight: 760;
}

.directory-progress span {
  color: var(--muted);
  font-size: 0.57rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.index-catalog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: rgba(251, 250, 246, 0.86);
}

.index-catalog-head {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 112px;
  gap: 24px;
  padding: 24px clamp(20px, 3vw, 42px) 17px;
  border-bottom: 3px solid var(--ink);
  background: rgba(251, 250, 246, 0.96);
}

.index-catalog-head .eyebrow {
  color: var(--pink);
}

.index-catalog-head h2 {
  margin: 6px 0 0;
  font-family: var(--display);
  font-size: clamp(2.1rem, 3.4vw, 3.8rem);
  font-weight: 520;
  letter-spacing: -0.06em;
  line-height: 0.9;
}

#visibleCount {
  flex: none;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.directory-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--muted) transparent;
  scrollbar-width: thin;
}

.directory-group {
  margin: 0;
}

.directory-group-heading {
  position: sticky;
  z-index: 3;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 7px clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--ink);
  color: var(--green);
  background: var(--paper-deep);
}

.directory-group-heading h3,
.directory-group-heading p {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.directory-group-heading p {
  color: var(--muted);
}

.directory-group-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.directory-row {
  position: relative;
  display: grid;
  min-height: 56px;
  grid-template-columns: 54px minmax(0, 1fr) minmax(88px, auto) auto 18px;
  gap: 12px;
  align-items: center;
  padding: 9px clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.directory-row::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--pink);
  content: "";
  transition: width 160ms ease;
}

.directory-row:hover::before,
.directory-row:focus-visible::before,
.directory-row.is-previewed::before {
  width: 7px;
}

.directory-row.is-previewed {
  color: var(--paper);
  background: var(--ink);
}

.directory-row.is-previewed .directory-code,
.directory-row.is-previewed .directory-meta {
  color: rgba(251, 250, 246, 0.72);
}

.directory-code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.65rem;
  font-weight: 760;
  letter-spacing: 0.06em;
}

.directory-title {
  min-width: 0;
  overflow: hidden;
  font-family: var(--display);
  font-size: clamp(1.15rem, 1.8vw, 1.65rem);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-meta {
  color: var(--muted);
  font-size: 0.59rem;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}

.directory-listened {
  padding: 4px 6px;
  border: 1px solid currentColor;
  color: var(--green);
  font-size: 0.53rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.directory-row.is-previewed .directory-listened {
  color: var(--acid);
}

.directory-arrow {
  color: var(--pink);
  font-size: 0.95rem;
}

.directory-empty {
  align-self: start;
  margin: 0;
  padding: 54px clamp(20px, 3vw, 42px);
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 3.5rem);
  font-weight: 540;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.index-preview {
  overflow-y: auto;
  border-left: 1px solid var(--ink);
  background: #f8e9ef;
}

.preview-link {
  display: grid;
  width: 100%;
  min-height: 100%;
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
  gap: 14px;
  padding: clamp(24px, 2.6vw, 34px);
  text-decoration: none;
}

.preview-index,
.preview-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--ink);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.preview-copy .eyebrow {
  color: var(--green);
}

.preview-copy h2 {
  margin: 10px 0 8px;
  font-family: var(--display);
  font-size: clamp(2.65rem, 4.3vw, 5rem);
  font-weight: 560;
  letter-spacing: -0.07em;
  line-height: 0.84;
}

.preview-copy > p:last-child {
  margin: 0;
  font-family: var(--reading);
  font-size: 0.92rem;
  line-height: 1.4;
}

.preview-figure {
  position: relative;
  display: grid;
  min-height: 0;
  align-content: center;
  justify-items: center;
  margin: 0;
  padding: 8px 8px 28px;
}

.preview-figure img {
  width: min(100%, 205px);
  max-height: 100%;
  object-fit: contain;
  box-shadow: 14px 14px 0 rgba(14, 98, 72, 0.16), 0 0 0 1px var(--ink);
  transform: rotate(1deg);
  transition: transform 180ms ease;
}

.preview-link:hover .preview-figure img {
  transform: rotate(0deg) translateY(-3px);
}

.preview-figure figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  max-width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--ink);
  background: var(--paper);
  font-size: 0.5rem;
  font-weight: 760;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.preview-action {
  align-self: end;
  padding: 12px 0 0;
  border-top: 1px solid var(--ink);
  border-bottom: 0;
}

.preview-action span:last-child {
  color: var(--pink);
  font-size: 1rem;
}

.load-error {
  margin: 24px;
  padding: 18px;
  border: 1px solid var(--ink);
  background: var(--paper);
}

@media (max-width: 1100px) {
  .living-index-page .index-shell {
    grid-template-columns: minmax(250px, 0.72fr) minmax(430px, 1.28fr);
  }

  .index-preview {
    display: none;
  }

  .directory-row.is-previewed {
    color: inherit;
    background: transparent;
  }

  .directory-row.is-previewed::before {
    width: 0;
  }

  .directory-row.is-previewed .directory-code,
  .directory-row.is-previewed .directory-meta {
    color: var(--muted);
  }

  .directory-row.is-previewed .directory-listened {
    color: var(--green);
  }
}

@media (max-width: 760px) {
  .living-index-page .atlas-header {
    min-height: 64px;
    padding-inline: 14px;
  }

  .living-index-page .index-shell {
    width: 100%;
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .index-controls {
    display: grid;
    grid-template-areas:
      "identity search"
      "filters filters"
      "actions actions";
    grid-template-columns: minmax(112px, 0.72fr) minmax(170px, 1.28fr);
    gap: 12px 16px;
    padding: 15px 16px 14px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .index-identity {
    grid-area: identity;
  }

  .index-identity .eyebrow,
  .index-identity > p:last-child {
    display: none;
  }

  .index-identity h1 {
    max-width: 6ch;
    margin: 0;
    font-size: clamp(2.2rem, 10vw, 3.3rem);
    line-height: 0.88;
  }

  .directory-search {
    align-self: end;
    grid-area: search;
    margin: 0;
    padding: 0;
  }

  .directory-search label {
    font-size: 0.57rem;
  }

  .search-field input {
    height: 44px;
    font-size: 0.86rem;
  }

  .directory-filter-block {
    grid-area: filters;
    margin: 0;
  }

  .directory-filter-block > p {
    margin-bottom: 6px;
    font-size: 0.57rem;
  }

  .directory-filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }

  .directory-filters button {
    min-width: 0;
    min-height: 31px;
    padding: 6px 3px;
    overflow: hidden;
    font-size: 0.55rem;
    letter-spacing: 0.035em;
    text-overflow: ellipsis;
  }

  .directory-actions {
    grid-area: actions;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 0;
  }

  .directory-actions button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 0.57rem;
  }

  .directory-context,
  .directory-progress {
    display: none;
  }

  .index-catalog-head {
    min-height: 68px;
    padding: 11px 16px 10px;
    border-bottom-width: 2px;
  }

  .index-catalog-head h2 {
    font-size: 2rem;
  }

  .index-catalog-head .eyebrow {
    font-size: 0.56rem;
  }

  .directory-group-heading {
    min-height: 31px;
    padding: 6px 16px;
  }

  .directory-row {
    min-height: 52px;
    grid-template-columns: 42px minmax(0, 1fr) auto 16px;
    gap: 8px;
    padding: 8px 16px;
  }

  .directory-title {
    font-size: 1.18rem;
  }

  .directory-meta {
    display: none;
  }

  .directory-listened {
    padding: 3px 5px;
  }

  .directory-empty {
    padding: 36px 16px;
    font-size: 2.25rem;
  }
}

@media (max-width: 420px) {
  .living-index-page .prototype-stamp {
    max-width: 76px;
  }

  .index-controls {
    grid-template-columns: minmax(104px, 0.68fr) minmax(165px, 1.32fr);
    padding-inline: 12px;
  }

  .index-identity h1 {
    font-size: 2.25rem;
  }

  .search-field input {
    padding-left: 10px;
    font-size: 0.78rem;
  }

  .search-field kbd {
    right: 8px;
  }

  .directory-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .index-catalog-head,
  .directory-group-heading,
  .directory-row {
    padding-inline: 12px;
  }

  #visibleCount {
    font-size: 0.58rem;
  }
}

@media (max-height: 720px) and (min-width: 761px) {
  .index-controls {
    padding-block: 22px;
  }

  .index-identity h1 {
    font-size: 3.4rem;
  }

  .index-identity > p:last-child {
    display: none;
  }

  .directory-search {
    padding-top: 18px;
  }

  .directory-progress {
    margin-top: 12px;
  }
}

@media (max-width: 760px) and (max-height: 650px) {
  html:has(.living-index-page) {
    height: auto;
    overflow: auto;
  }

  .living-index-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .living-index-page .index-shell {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .index-catalog {
    height: 560px;
    min-height: 560px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .directory-row::before,
  .preview-figure img {
    transition: none;
  }
}
