@layer pages {
  /* Event page: picture, details, and the ticket box (a sticky side box on wide screens, a bottom bar on phones). */
  .event-back { padding-block: var(--space-4) var(--space-2); }
  .event-hero { position: relative; }
  .event-hero__image { display: block; inline-size: 100%; aspect-ratio: 16 / 7; max-block-size: 26rem; object-fit: cover; border-radius: var(--radius-lg); }
  .event-hero__image { border-radius: var(--radius-xl); }
  /* A square or tall picture (a flyer) is shown whole, at most as large as it really is, on a soft band; cropping it into
     the wide banner would cut off the date and place and blur it. */
  .event-hero--whole .event-hero__image { inline-size: auto; max-inline-size: 100%; block-size: auto; aspect-ratio: auto; max-block-size: 34rem; margin-inline: auto; object-fit: contain; border-radius: var(--radius-lg); }
  .event-hero--whole { display: grid; }
  .event-hero--whole::before { content: ""; grid-area: 1 / 1; background: var(--color-tint); border-radius: var(--radius-xl); }
  .event-hero--whole .event-hero__image { grid-area: 1 / 1; align-self: center; margin-block: var(--space-4); }
  .event-hero__category { position: absolute; inset-block-start: var(--space-4); inset-inline-start: var(--space-4); }
  /* "Sponsored by" floats over the picture's lower right corner; the sponsors section below has the logos and links. */
  .event-hero__sponsors { position: absolute; inset-block-end: var(--space-4); inset-inline-end: var(--space-4); inline-size: fit-content; max-inline-size: calc(100% - var(--space-6)); margin: 0; padding: var(--space-2) var(--space-4); display: flex; flex-wrap: wrap; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-ink); background: color-mix(in srgb, var(--color-surface) 94%, transparent); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
  .event-hero__sponsors span { color: var(--color-ink-soft); }
  .event-hero__open { display: block; border-radius: var(--radius-xl); cursor: zoom-in; }
  .event-hero__open:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
  .event-hero--whole .event-hero__open { grid-area: 1 / 1; display: grid; }
  /* Phones: every picture is the same height (wide ones cropped, flyers whole on their band), and the title and gaps
     are smaller, so the date, place and price show as the page opens. Tapping the picture shows it whole. */
  @media (max-width: 40rem) {
    .event-hero__image { aspect-ratio: auto; block-size: 13rem; max-block-size: none; }
    .event-hero--whole .event-hero__image { block-size: 11.5rem; max-block-size: none; margin-block: 0.75rem; }
    .event-layout { gap: var(--space-4); }
    .event-main h1 { font-size: 1.75rem; }
  }
  /* The full-screen picture viewer. */
  .image-viewer:modal {
    inset: 0; inline-size: 100%; max-inline-size: none; block-size: 100%; max-block-size: none; margin: 0;
    padding: var(--space-4); border: 0; background: rgb(0 0 0 / 0.92); overscroll-behavior: contain; cursor: zoom-out;
  }
  .image-viewer[open] { display: grid; place-items: center; }
  .image-viewer::backdrop { overflow: hidden; overscroll-behavior: contain; }
  .image-viewer__image { grid-area: 1 / 1; max-inline-size: 100%; max-block-size: calc(100dvh - 2 * var(--space-4)); object-fit: contain; }
  .image-viewer__close { position: fixed; inset-block-start: var(--space-4); inset-inline-end: var(--space-4); z-index: 1; }

  .event-layout { display: grid; gap: var(--space-6); align-items: start; padding-block-end: var(--space-7); }
  @media (min-width: 56rem) {
    .event-layout { grid-template-columns: minmax(0, 1fr) 24rem; }
    .event-aside { position: sticky; inset-block-start: 6rem; }
  }
  .event-main h1 { font-size: var(--text-3xl); line-height: 1.02; }
  .event-facts { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
  .event-facts .pill { display: inline-flex; align-items: center; gap: var(--space-2); min-block-size: 2.5rem; max-inline-size: none; padding-inline: var(--space-3); font-size: var(--text-sm); font-weight: 600; color: var(--color-ink); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-pill); }
  .event-facts .pill .icon { color: var(--color-primary); }
  .event-actions .button { gap: var(--space-2); }
  .event-main h2 { font-size: var(--text-xl); }
  .prose { font-size: var(--text-lg); line-height: 1.7; color: var(--color-ink-soft); }
  .event-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .prose > :first-child { margin-block-start: 0; }

  .ticket-box { padding: var(--space-5); }
  /* Choosing tickets: each line is its label and price with a small quantity box beside it, so the whole choice fits
     next to the picture without scrolling. */
  .ticket-box .ticket-group { display: grid; gap: var(--space-2); }
  .ticket-box .ticket-group__title { margin: 0; font-weight: 700; }
  .ticket-box .ticket-line { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
  .ticket-box .ticket-line > input { inline-size: 4.5rem; min-block-size: 2.25rem; flex: none; text-align: center; }
  .ticket-box .ticket-people { display: grid; gap: var(--space-2); margin: 0; padding: 0; border: 0; min-inline-size: 0; }
  .ticket-box .ticket-people legend { padding: 0; margin-block-end: var(--space-2); }
  .ticket-box .ticket-people .check { min-block-size: 2.25rem; align-items: center; }
  .ticket-box .ticket-people .check input { margin-block-start: 0; }
  .ticket-box .ticket-people .check:has(input:disabled) { cursor: not-allowed; color: var(--color-muted); }
  .ticket-box .ticket-group > p { margin: 0; font-size: var(--text-sm); }
  .ticket-box .ticket-group > .ticket-group__title { font-size: var(--text-md); }
  .ticket-box form { display: grid; gap: var(--space-4); }
  /* Thin rules keep the pieces apart: under the heading, between ticket kinds, and above the purchase note. */
  .ticket-box__head { padding-block-end: var(--space-3); border-block-end: 1px solid var(--color-border); }
  .ticket-box .ticket-group { gap: var(--space-3); }
  .ticket-box .ticket-group + .ticket-group { padding-block-start: var(--space-4); border-block-start: 1px solid var(--color-border); }
  .ticket-box .ticket-group ~ p { padding-block-start: var(--space-4); border-block-start: 1px solid var(--color-border); }
  .ticket-box .ticket-line { padding-block: var(--space-1); }
  .ticket-box .ticket-line + .ticket-line { border-block-start: 1px dashed var(--color-border); padding-block-start: var(--space-2); }
  .ticket-box form > p { margin: 0; font-size: var(--text-sm); }
  .ticket-box h2 { font-size: var(--text-lg); margin: 0; }
  .ticket-box h3 { font-size: var(--text-md); }
  .ticket-box > * { margin-block: 0; }
  .ticket-box__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
  .ticket-box__price { font-size: var(--text-md); }
  .ticket-note { margin-block-start: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--color-band); border-color: transparent; font-size: var(--text-sm); }
  .ticket-note a { font-weight: 700; }

  /* On phones the box is reached from a bar fixed to the bottom of the screen, just above the footer's language and
     appearance bar (which would otherwise cover it). */
  .ticket-bar { position: fixed; inset-inline: 0; inset-block-end: calc(var(--footer-bar-size, 0px) + env(safe-area-inset-bottom, 0px)); z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--color-surface); border-block-start: 1px solid var(--color-border-strong); box-shadow: var(--shadow-raised); }
  .ticket-bar__price { margin: 0; font-size: var(--text-sm); }
  @media (max-width: 55.99rem) { .event-layout { padding-block-end: 6rem; } }
  @media (min-width: 56rem) { .ticket-bar { display: none; } }

  .event-sponsors { list-style: none; margin: 0; padding: 0; max-inline-size: none; display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-5); align-items: center; }
  .event-sponsors__item { display: flex; align-items: center; gap: var(--space-3); font: 600 var(--text-md) var(--font-display); }
  .event-sponsors__logo { block-size: 3rem; inline-size: auto; max-inline-size: 8rem; object-fit: contain; }
}
