/* ==========================================================================
   Salafi Lessons display: the timetable page and the homepage blocks.
   Tokens are copied from Salafi Prayer Times so the two plugins read as one
   family; the compositions are Lessons' own (SL-D-091). Scoped to .sld,
   never :root. Dark is opt-in per block (theme="dark"). Every layout change
   is a container query on the block, so it fits the column it sits in.
   ========================================================================== */

.sld {
  --sld-text: #1f1e1c;
  --sld-muted: #5b5955;
  --sld-card: #ffffff;
  --sld-well: #f4f3f0;
  --sld-line: #e6e4df;
  --sld-line-strong: rgba(31, 30, 28, 0.16);
  --sld-accent: var(--sld-text);
  --sld-accent-well: var(--sld-well);
  --sld-shadow: 0 1px 2px rgba(31, 30, 28, 0.05), 0 12px 32px -12px rgba(31, 30, 28, 0.14);
  --sld-r-xs: 8px;
  --sld-r-sm: 12px;
  --sld-r: 16px;
  --sld-ease: cubic-bezier(0.23, 1, 0.32, 1);
  --sld-font: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  /* One inner edge for rows, headings and links: the next-class well fills
     the row without reaching past the column, and all text lines up. */
  --sld-inset: 0.5rem;

  container-type: inline-size;
  color: var(--sld-text);
  font-family: var(--sld-font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

.sld[data-theme="dark"] {
  color-scheme: dark;
  --sld-text: #f2f1ee;
  --sld-muted: #c9c6bf;
  --sld-card: #1b1a19;
  --sld-well: rgba(255, 255, 255, 0.07);
  --sld-line: rgba(255, 255, 255, 0.12);
  --sld-line-strong: rgba(255, 255, 255, 0.22);
  --sld-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -14px rgba(0, 0, 0, 0.55);
}

.sld,
.sld *,
.sld *::before,
.sld *::after {
  box-sizing: border-box;
}

/* The theme styles bare headings, paragraphs and lists; these start clean. */
.sld :is(h3, h4, p, ul, li, figure) {
  margin: 0;
  padding: 0;
  font-family: inherit;
  letter-spacing: 0;
  text-transform: none;
}

.sld time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.sld :focus-visible {
  outline: 2px solid var(--sld-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.sld .sld-empty {
  color: var(--sld-muted);
  font-size: 0.9375rem;
}

.sld .sld-empty + .sld-empty {
  margin-top: 0.25rem;
}

.sld .sld-empty a {
  color: var(--sld-text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.sld-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- One row, three densities -------------------------------------------- */

.sld-rows {
  display: flex;
  flex-direction: column;
}

.sld-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) auto;
  column-gap: 0.75rem;
  align-items: start;
  padding: 0.625rem var(--sld-inset);
  border-top: 1px solid var(--sld-line);
  border-radius: var(--sld-r-xs);
}

.sld-rows > .sld-row:first-child {
  border-top-color: transparent;
}

.sld-when {
  display: flex;
  flex-direction: column;
  padding-top: 0.0625rem;
}

.sld .sld-start {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.sld .sld-end {
  color: var(--sld-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}

.sld-what {
  min-width: 0;
}

/* Lesson covers (SL-D-096) show only on the wide agenda, in the container query below. */
.sld-thumb {
  display: none;
}

.sld .sld-title {
  color: var(--sld-text);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.sld .sld-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--sld-line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 150ms ease;
}

.sld .sld-link:hover,
.sld .sld-link:focus-visible {
  text-decoration-color: currentColor;
}

.sld .sld-meta {
  margin-top: 0.125rem;
  color: var(--sld-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.sld .sld-note {
  margin-top: 0.1875rem;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.sld-tag {
  margin-top: 0.0625rem;
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  background: var(--sld-well);
  color: var(--sld-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}


/* highlight="next" (SL-D-092): the next class takes the accent, a light well and weight. */
.sld-row.is-next {
  background: var(--sld-accent-well);
  border-top-color: transparent;
}

.sld-row.is-next + .sld-row {
  border-top-color: transparent;
}

.sld .sld-row.is-next .sld-start {
  color: var(--sld-accent);
}

.sld .sld-row.is-next .sld-title {
  font-weight: 750;
}

.sld-row.is-next .sld-tag {
  background: var(--sld-card);
}

/* With the highlight, finished classes stay readable and step back. */
.sld .sld-row.is-done .sld-start,
.sld .sld-row.is-done .sld-title {
  color: var(--sld-muted);
}

.sld .sld-row.is-done .sld-start {
  font-weight: 600;
}

/* ---- view="week": an agenda ----------------------------------------------- */

.sld-week {
  container-name: sld-week;
  max-width: 72rem;
}

.sld-week.sld:not(.is-frameless) {
  padding: 1.25rem;
  background: var(--sld-card);
  border: 1px solid var(--sld-line);
  border-radius: var(--sld-r);
  box-shadow: var(--sld-shadow);
}

.sld-week-grid {
  display: grid;
  gap: 1.75rem;
  align-items: start;
}

.sld-week-main {
  min-width: 0;
}

.sld .sld-range,
.sld .sld-empty {
  padding-inline: var(--sld-inset);
}

.sld .sld-range {
  margin-bottom: 1rem;
  color: var(--sld-muted);
  font-size: 0.9375rem;
  font-weight: 600;
}

.sld-days {
  display: flex;
  flex-direction: column;
}

/* A hairline between days on a phone too, as on a wide page. */
.sld-days > .sld-day + .sld-day {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--sld-line);
}

/* mobile="compact" (SL-D-095): a narrow page shows the compact week; the full
   rows return when there is room for the agenda. */
.sld-week .sld-cdays {
  display: none;
}

.sld-week.has-compact .sld-days {
  display: none;
}

.sld-week.has-compact .sld-cdays {
  display: flex;
}

.sld .sld-day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.125rem 0.5rem;
  margin-bottom: 0.125rem;
  padding-inline: var(--sld-inset);
  color: var(--sld-text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.3;
}

.sld-day-date {
  color: var(--sld-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}


.sld .sld-day.is-past .sld-day-head {
  color: var(--sld-muted);
}

.sld-poster {
  display: grid;
  gap: 0.625rem;
  width: 100%;
  max-width: 22rem;
  padding-inline: var(--sld-inset);
}

.sld .sld-poster-open {
  display: block;
  overflow: hidden;
  border-radius: var(--sld-r-sm);
  background: var(--sld-well);
  box-shadow: var(--sld-shadow);
  line-height: 0;
}

.sld .sld-poster-open img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1080 / 1350;
}

.sld .sld-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.625rem 1rem;
  border: 1px solid var(--sld-line-strong);
  border-radius: var(--sld-r-sm);
  color: var(--sld-text);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: transform 120ms var(--sld-ease);
}

.sld .sld-download:active {
  transform: scale(0.97);
}

.sld-download svg {
  flex: none;
}

/* Room for it: the day moves to a left column, like a printed timetable. */
@container sld-week (min-width: 38rem) {
  .sld-days {
    gap: 0;
  }

  .sld-day {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr);
    column-gap: 1.5rem;
    padding-block: 0.75rem;
    border-top: 1px solid var(--sld-line);
  }

  .sld-days > .sld-day:first-child {
    padding-top: 0;
    border-top: 0;
  }

  .sld-days > .sld-day + .sld-day {
    margin-top: 0;
    padding-top: 0.75rem;
  }

  .sld-week.has-compact .sld-days {
    display: flex;
  }

  .sld-week.has-compact .sld-cdays {
    display: none;
  }

  .sld .sld-day-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding-top: 0.625rem;
  }

  .sld-row {
    grid-template-columns: 5.5rem minmax(0, 1fr) auto;
    column-gap: 1rem;
  }

  /* Every row gets the same square, so the names start in one line. */
  .sld-week.has-thumbs .sld-row {
    grid-template-columns: 5.5rem 3rem minmax(0, 1fr) auto;
  }

  .sld-week.has-thumbs .sld-thumb {
    display: block;
    width: 3rem;
    height: 3rem;
    overflow: hidden;
    border-radius: var(--sld-r-xs);
    background: var(--sld-well);
    box-shadow: inset 0 0 0 1px var(--sld-line);
  }

  .sld-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

/* Wider still: the poster becomes a rail beside the week and stays in view. */
@container sld-week (min-width: 60rem) {
  .sld-week-grid {
    grid-template-columns: minmax(0, 1fr) 17.5rem;
    column-gap: 3rem;
  }

  .sld-poster {
    position: sticky;
    top: 1.5rem;
  }
}

/* ---- view="poster": the poster alone -------------------------------------- */

.sld-poster-only .sld-poster {
  max-width: 28rem;
  padding-inline: 0;
}

/* ---- The homepage blocks --------------------------------------------------- */

.sld-block {
  container-name: sld-block;
  padding: 1.125rem calc(1.125rem - var(--sld-inset));
  background: var(--sld-card);
  border: 1px solid var(--sld-line);
  border-radius: var(--sld-r);
  box-shadow: var(--sld-shadow);
}

.sld-block.is-frameless {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.sld-block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.125rem 1rem;
  margin-bottom: 0.5rem;
  padding-inline: var(--sld-inset);
}

.sld .sld-block-title {
  color: var(--sld-text);
  font-size: 1.0625rem;
  font-weight: 750;
  letter-spacing: -0.012em;
  line-height: 1.25;
}

.sld .sld-block-date {
  color: var(--sld-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.sld .sld-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 44px;
  margin-top: 0.5rem;
  padding: 0.5rem var(--sld-inset) 0;
  border-top: 1px solid var(--sld-line);
  color: var(--sld-text);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
}

.sld-more svg {
  flex: none;
  color: var(--sld-muted);
  transition: transform 150ms var(--sld-ease), color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .sld-more:hover svg {
    color: var(--sld-accent);
    transform: translateX(2px);
  }
}

/* view="today": the next class leads, a little louder than the rest. */
.sld .sld-today .sld-row.is-next .sld-start {
  font-size: 1.1875rem;
  letter-spacing: -0.01em;
}

.sld .sld-today .sld-row.is-next .sld-title {
  font-size: 1.0625rem;
}

/* view="compact": one line a class, days down the side. */
.sld-cdays {
  display: flex;
  flex-direction: column;
}

.sld-cday {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  column-gap: 0.625rem;
  padding: 0.5rem var(--sld-inset);
  border-top: 1px solid var(--sld-line);
}

.sld-cdays > .sld-cday:first-child {
  border-top-color: transparent;
}

.sld .sld-cday-name {
  padding-top: 0.0625rem;
  color: var(--sld-text);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.35;
}

.sld .sld-clist {
  display: grid;
  gap: 0.125rem;
  list-style: none;
}

.sld .sld-clist li {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr);
  column-gap: 0.5rem;
  padding: 0.125rem 0;
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.35;
}

.sld-clist time {
  font-weight: 700;
  white-space: nowrap;
}

.sld-ctitle {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.sld .sld-cday.is-today .sld-cday-name {
  color: var(--sld-accent);
}

.sld .sld-cday.is-past .sld-cday-name,
.sld .sld-clist li.is-done time,
.sld .sld-clist li.is-done .sld-ctitle {
  color: var(--sld-muted);
  font-weight: 600;
}

.sld .sld-clist li.is-next {
  margin-inline: -0.375rem;
  padding: 0.25rem 0.375rem;
  background: var(--sld-accent-well);
}

.sld .sld-clist li.is-next time,
.sld .sld-clist li.is-next .sld-ctitle {
  color: var(--sld-accent);
}

.sld .sld-clist li.is-next .sld-ctitle {
  font-weight: 750;
}

/* The blocks always list classes in one column (SL-D-094); a wide one just
   gives the times a little more room. */
@container sld-block (min-width: 36rem) {
  .sld-row {
    grid-template-columns: 5.5rem minmax(0, 1fr) auto;
    column-gap: 1rem;
  }

  .sld-cday {
    grid-template-columns: 3rem minmax(0, 1fr);
    column-gap: 1rem;
  }

  .sld .sld-clist li {
    grid-template-columns: 5rem minmax(0, 1fr);
    column-gap: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sld,
  .sld * {
    transition: none !important;
  }
}
