@layer components {
  /* Event column layout
  /* ------------------------------------------------------------------------ */

  .events {
    --events-gap: 1ch;
    --events-border: 1px solid var(--color-ink-lighter);
    --events-day-header-height: 1.75rem;
  }

  .events__day {
    position: relative;

    @media (max-width: 639px) {
      margin-block-end: calc(var(--events-gap) * 2);
    }
  }

  .events__day-header,
  .events__column-header {
    font-size: var(--text-small);
    text-align: center;
    text-transform: uppercase;
  }

  .events__day-header {
    block-size: 0;
    inset-block-start: calc(var(--events-day-header-height) / 2);
    position: sticky;
    z-index: var(--z-events-day-header);

    time {
      align-items: center;
      background-color: var(--color-ink);
      block-size: var(--events-day-header-height);
      border-radius: 0.2em;
      display: flex;
      inline-size: fit-content;
      inset: 0 auto auto 50%;
      margin-inline: auto;
      padding-inline: 1.5ch;
      position: absolute;
      translate: -50% -50%;
    }
  }

  .events__columns {
    border-block-start: var(--events-border);
    position: relative;

    @media (min-width: 640px) {
      align-items: end;
      border-inline: var(--events-border);
      display: grid;
      grid-template-columns: repeat(3, 1fr);

      /* Pseudo column borders since .events__column is display: contents */
      &:before,
      &:after {
        border-inline-start: var(--events-border);
        content: "";
        inset-block: 0;
        position: absolute;
        z-index: var(--z-events-day-header);
      }

      &:before { inset-inline-start: calc(100% / 3); }
      &:after { inset-inline-end: calc(100% / 3); }
    }
  }

  .events__column {
    @media (max-width: 639px) {
      &:not(:has(.event)) {
        display: none;
      }
    }

    @media (min-width: 640px) {
      display: contents;
    }

    &:nth-of-type(1) > * { grid-column-start: 1; }
    &:nth-of-type(2) > * { grid-column-start: 2; }
    &:nth-of-type(3) > * { grid-column-start: 3; }
  }

  .events__column-header {
    background-color: var(--color-canvas);
    grid-row-start: 1;
    inset-block-start: 0;
    margin-block-end: var(--events-gap);
    padding-block: calc(var(--events-gap) * 3) var(--events-gap);
    position: sticky;
    z-index: var(--z-events-column-header);
  }

  .events__time-block {
    align-content: end;
    display: grid;
    gap: var(--events-gap);
    justify-items: center;
    margin: 0;
    padding: 0;

    @media (min-width: 640px) {
      padding-block-end: calc(var(--events-gap) * 3);
      padding-inline: calc(var(--events-gap) * 2);
    }

    .event {
      grid-column-start: unset !important;
      grid-row-start: unset !important;
    }
  }

  .events__none {
    background-color: var(--color-canvas);
    border-block-start: var(--events-border);
    grid-column: 1 / -1;
    padding-block: 3em;
    text-align: center;
  }

  /* Event
  /* ------------------------------------------------------------------------ */

  .event {
    --column-gap: 0.7ch;
    --panel-border-color: transparent;
    --panel-border-radius: 0.2em;
    --panel-padding: 0.6em;
    --panel-size: auto;

    margin: var(--inline-space);
    max-inline-size: 100%;
    min-inline-size: 0;
    overflow: clip;
    position: relative;
    z-index: 0;

    @media (max-width: 639px) {
      --panel-size: 100%;
    }

    &:has(.card__background img:not([src=""])) {
      background-color: var(--color-canvas) !important;
    }

    .card__background {
      filter: brightness(1.2) contrast(0.8);
      opacity: 0.2;
      z-index: 0;
    }

    .card__collection {
      background-color: transparent;
      color: color-mix(in srgb, var(--card-color) 40%, var(--color-ink));
      font-size: 0.7em;
      margin:  calc(var(--panel-padding) * -0.5) 0 var(--panel-padding) 0;
      padding: 0;
    }

    .card__collection-name {
      border-inline-start: 1px solid color-mix(in srgb, var(--color-ink) 33%, var(--color-canvas));
      color: color-mix(in srgb, var(--card-color) 40%, var(--color-ink));
      margin: 0 0 0 calc(var(--inline-space) * 0.75);
    }

    .card__header {
      overflow: visible;
    }

    .card__id {
      margin: 0;
    }
  }

  .event--golden {
    --lch-golden: 89.1% 0.178 95.7;

    background-color: var(--color-canvas) !important;
    background-image: linear-gradient(60deg,
      oklch(var(--lch-golden) / 0.5) 0%,
      oklch(var(--lch-golden) / 0.15) 33%,
      oklch(var(--lch-golden) / 0.05) 66%,
      oklch(var(--lch-golden) / 0.5) 100%
    );
    border-color: var(--color-ink-lighter) !important;
    box-shadow:
      0 0 0 1px oklch(var(--lch-golden) / 75%),
      0 0 0.2em 0.2em oklch(var(--lch-golden) / 25%),
      0 0 .7em 0.5em oklch(var(--lch-golden) / 25%);

    @media (prefers-color-scheme: dark) {
      --lch-golden: var(--lch-blue-medium);
    }
  }

  .event--related {
    --hover-color: var(--card-color);
    --hover-size: 0.15rem;

    box-shadow: 0 0 0 var(--hover-size) var(--hover-color);
  }

  .event__content {
    max-inline-size: 100%;
    position: relative;
    z-index: 1;
  }

  .event__grid-item {
    background-color: var(--color-canvas);
    block-size: 100%;
    border-radius: 0;
    display: flex;
    inline-size: 100%;
  }

  .event__grid-column-title {
    --z: 3;

    background-color: var(--color-canvas);
    font-size: 0.9em;
    padding: 1.5em 0 1em;
    text-transform: uppercase;
  }

  .event__icon {
    display: grid;
    margin: -0.3em -0.3em auto auto;
    place-content: center;

    .icon {
      background-color: var(--card-color);
      block-size: 1em;
      inline-size: 1em;
      grid-area: 1 / 1;
    }
  }

  .event__timestamp {
    align-self: start;
    display: grid;
    font-weight: 600;
    margin-block-end: var(--block-space-half);
  }

  .event__title {
    --lines: 4;

    font-size: 1.1em;
    line-height: 1.2;
  }
}
