/*
 * The template library, /templates: every template as the whole page it
 * makes, lined up so two can be compared at a glance, and the date preview
 * folded away until it is asked for (docs/TEMPLATE_LIBRARY_OPTIONS.md).
 */

body:has(.library) main { max-width: 78rem; }

.library-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.library-bar h1 { margin: 0; }

/* Closed, the preview is one button at the right of the title. Open, it
   takes the row below and the button stays where the eye left it. */
.library-preview summary { display: block; list-style: none; cursor: pointer; width: max-content; margin-left: auto; }
.library-preview summary::-webkit-details-marker { display: none; }
.library-preview[open] { flex-basis: 100%; }
.library-preview[open] summary { background: #eef0f6; }
.library-preview__body {
  margin-top: 0.6rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
}
.library-preview__day { font-size: 0.95rem; margin: 1rem 0 0.4rem; }
.library-preview__body .preview { margin-top: 0.9rem; }

.library-section { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem; margin: 1.75rem 0 0.75rem; }
.library-section h2 { margin: 0; }
.library-section__about { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.875rem; }
.library-section form { display: inline; }
.library-new { display: inline-flex; align-items: center; gap: 0.35rem; }

/* Columns as wide as a whole thumbnail, and every card in a row stretched
   to the tallest, so the pages start level and the buttons end level. */
.library-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
  gap: 1.25rem 1rem;
  margin: 0 0 1rem;
}

.library-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-width: 0;
  border: 1px solid #e2e5ee;
  border-top-width: 3px; /* every card, so a layer's colour moves nothing */
  border-radius: 6px;
  background: #fff;
}
.library-card--layer { border-top-color: var(--accent); }
.library-card--paused .library-card__thumb { opacity: 0.55; }

.library-card__name {
  margin: 0;
  padding: 0.6rem 0.85rem 0.5rem;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-card__name a { color: inherit; text-decoration: none; }
.library-card__name a:hover { text-decoration: underline; }

/* The whole page, top to bottom, at a quarter of a sheet pixel. */
.library-card__thumb {
  --u: 0.21px;
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
  border-block: 1px solid #eef0f6;
  background: #fafbfd;
  overflow: hidden;
}
.library-card__thumb .sheet { margin: 0; padding-top: 0; }
.library-card__thumb .sheet, .library-card__thumb .weekgrid { pointer-events: none; }

.library-card__meta { display: grid; align-content: start; gap: 0.1rem; padding: 0.5rem 0.85rem 0; font-size: 0.8rem; color: var(--muted); }
.library-card__base { color: var(--accent); }
.library-card__idle { color: #9a6b3b; }

.library-card__actions { display: flex; align-items: center; gap: 0.35rem; padding: 0.6rem 0.85rem 0.7rem; }
.library-card__actions .button { font-size: 0.8rem; padding: 0.25rem 0.55rem; line-height: 1.3; }
.library-card__actions form { display: inline; margin: 0; }
.library-from summary { display: inline-flex; align-items: center; gap: 0.25rem; }
.library-from[open] summary { background: #eef0f6; }
.library-from__list { left: 0; right: auto; width: 17rem; }
.library-delete__form, .library-card__actions > .library-delete { margin-left: auto !important; }
.library-delete { color: var(--muted); }
.library-delete:hover:not(:disabled) { color: #b42318; border-color: #f1c4bf; background: #fef3f2; }
.library-delete:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- why a date gets what it gets ------------------------------------- */

.why { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.3rem; }
.why__claim {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
  margin: 0;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  font-size: 0.875rem;
}
.why__claim a { font-weight: 600; }
.why__claim--wins { border-color: var(--ok); background: #f3faf5; }
.why__claim--out { opacity: 0.7; }
.why__claim--out a { text-decoration: line-through; }
.why__verdict { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.why__claim--wins .why__verdict { color: var(--ok); font-weight: 600; }
.why__when { color: var(--muted); }

/* ---- where a card template's card lands -------------------------------- */

/* The next day it goes on, small and read-only, with the card picked out --
   apart from the editor, which shows the card alone (day_templates/_card_landing). */
.card-landing {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: flex-start;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #e2e5ee;
  border-radius: 6px;
  background: #fff;
}
.card-landing__said { flex: 1 1 18rem; max-width: 34rem; font-size: 0.9rem; }
.card-landing__said h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.card-landing__said p { margin: 0 0 0.4rem; }
.card-landing__day {
  --u: 0.3px;
  flex: none;
  padding: 0.4rem;
  background: #fafbfd;
  border: 1px solid #eef0f6;
  border-radius: 4px;
  pointer-events: none;
}
.card-landing__day .sheet { margin: 0; padding-top: 0; }
.card-landing__day .card:not(.card--highlight) { opacity: 0.4; }
.card-landing__day .card--highlight { outline: 3px solid var(--accent); outline-offset: 2px; }
