/* Titles of the atelier's views */
.atelier-title {
  font-family: var(--font-book);
  font-size: 44px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.05;
  margin: 0;
}

.atelier-subtitle {
  color: var(--ink-3);
  font-size: 13.5px;
  margin-block: 8px 0;
}

/* Plan: the chapters of the book, as cards or as rows */
.plan {
  animation: fade 250ms ease;
  margin-inline: auto;
  max-inline-size: 1040px;
  padding-inline: clamp(0px, 2vw, 12px);
  text-align: start;
}

.plan__header {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-block: 16px 28px;

  form {
    display: contents;
  }
}

.plan__heading {
  flex: 1;
  margin-inline-end: 14px;
  min-inline-size: min(100%, 280px);
}

.plan__views {
  border-radius: var(--radius);
  padding: 3px;

  label {
    block-size: 30px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    display: grid;
    inline-size: 34px;
    place-items: center;

    input {
      appearance: none;
      block-size: 0;
      inline-size: 0;
      margin: 0;
      position: absolute;
    }

    img {
      opacity: 0.65;
    }

    &:has(:checked) {
      background: var(--surface);
      box-shadow: var(--shadow-sel);
    }

    &:has(:focus-visible) {
      outline: 2px solid var(--accent);
    }
  }
}

.plan__arrange {
  input {
    appearance: none;
    block-size: 0;
    inline-size: 0;
    margin: 0;
    position: absolute;
  }

  &:has(:checked) {
    --btn-background: var(--accent-tint);
    --btn-hover-background: var(--accent-tint);

    box-shadow: inset 0 0 0 1.5px var(--accent);
  }
}

.plan__blank-slate {
  color: var(--ink-3);
  display: none;
  font-size: 13.5px;

  .plan:not(:has(.plan-card)) & {
    display: block;
  }
}

.plan__leaves {
  margin: 0;
  outline: 0;
  padding: 0;

  > turbo-frame {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  }
}

.plan-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  list-style: none;
  padding: 12px 12px 14px;
  position: relative;
  transition: transform 150ms ease, box-shadow 150ms ease;

  &:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
  }

  &:has(.plan-card__link:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

/* The whole card opens the chapter */
.plan-card__link {
  border-radius: inherit;
  inset: 0;
  position: absolute;
  z-index: 1;
}

.plan-card__handle {
  display: none;
  flex-shrink: 0;
  opacity: 0.3;
}

.plan-card__sheet {
  background: var(--bg-flat);
  block-size: 150px;
  border-radius: var(--radius-sheet);
  color: oklch(48% 0.045 300);
  display: block;
  font-size: 8.5px;
  inline-size: 100%;
  line-height: 1.5;
  mask-image: linear-gradient(black 60%, transparent);
  overflow: hidden;
  padding: 10% 9%;
  text-align: justify;

  img {
    block-size: 100%;
    inline-size: 100%;
    object-fit: cover;
  }
}

.plan-card__sheet-title {
  display: block;
  font-size: 1.5em;
  font-weight: 700;
  margin-block: 6% 8%;
  text-align: center;
}

.plan-card__row {
  align-items: center;
  display: flex;
  gap: 10px;
  inline-size: 100%;
  min-inline-size: 0;

  .workshop__stage {
    block-size: 8px;
    inline-size: 8px;
  }

  .input {
    flex: 1;
    min-inline-size: 0;
    position: relative;
    z-index: 2;
  }

  .btn {
    position: relative;
    z-index: 2;
  }
}

.plan-card__title {
  flex: 1;
  font-size: 13.5px;
  font-weight: 700;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-card__meta {
  color: var(--ink-3);
  flex-shrink: 0;
  font-size: 11.5px;
}

/* "p. 5 · 1 284 mots": the separator only when the page number is known */
.plan-card__meta [data-pagination-target]:not(:empty) + .plan-card__words::before {
  content: " · ";
}

.plan-card__discard {
  inset: 8px 8px auto auto;
  position: absolute;
  z-index: 2;
}

.plan-card--last-read {
  box-shadow: var(--shadow-card), inset 0 0 0 1.5px var(--accent);
}

/* List: rows rather than cards */
.plan:has(#toc-list:checked) {
  .plan__leaves > turbo-frame {
    gap: 8px;
    grid-template-columns: 1fr;
  }

  .plan-card {
    align-items: center;
    flex-direction: row;
    padding: 10px 14px;
  }

  .plan-card__sheet {
    display: none;
  }

  .plan-card__handle {
    display: block;
  }
}

/* Reordering: the moving copies of the cards are placed by the controller */
.plan__layer {
  inset: 0;
  list-style: none;
  pointer-events: none;
  position: absolute;
}

/* Reordering */
.plan:has(#arrange-mode:checked) {
  .plan-card {
    cursor: grab;
  }

  .plan-card__link {
    display: none;
  }

  .plan-card__handle {
    opacity: 0.7;
  }
}

.plan-card.arrangement-selected {
  box-shadow: var(--shadow-card), inset 0 0 0 2px var(--accent);
}

.plan-card.arrangement-placeholder {
  opacity: 0.35;
}
