/*
 * Public pages on gatherment.events: an event, a guest's ticket and a workspace's events.
 * Every theme draws the same markup (app/views/public); a theme only changes layout, backgrounds and custom properties.
 * The brand sets --accent and --accent-ink on <html> (PublicHelper#brand_style), and data-font picks the display face.
 */

/* Fraunces, self-hosted under the OFL (app/assets/fonts/FRAUNCES-OFL-LICENSE.txt). Browsers fetch it only where it's used. */
@font-face {
  font-family: "Fraunces Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/assets/fraunces-latin-wght-normal-0f433db6.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Fraunces Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/assets/fraunces-latin-ext-wght-normal-25d26e47.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@layer layouts {
  html[data-theme] { --font-display: var(--font-sans); --display-weight: var(--weight-bold); --display-tracking: var(--tracking-display); }
  html[data-font="serif"] { --font-display: "Fraunces Variable", ui-serif, Georgia, serif; --display-weight: 600; --display-tracking: -0.03em; }

  .public { min-height: 100dvh; }

  /* The top: the brand's colour, its text in ink or white, whichever reads. */
  .hero {
    --fill: var(--color-surface);

    position: relative;
    display: grid;
    gap: var(--space-4);
    align-content: start;
    padding: var(--space-8) max(var(--gutter), calc((100% - var(--content-width)) / 2 + var(--gutter))) var(--space-4);
    background: var(--accent);
    color: var(--accent-ink);
  }

  .hero__brand {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    justify-self: start;
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-title);
    text-decoration: none;
  }

  .hero__logo { width: 2.5rem; height: 2.5rem; border-radius: var(--radius-sm); object-fit: cover; }
  .hero__wordmark { width: auto; height: 3rem; max-width: min(18rem, 70vw); object-fit: contain; object-position: left; }
  [data-theme="split"] .hero__wordmark { object-position: center; }

  .hero__title {
    font-family: var(--font-display);
    font-size: clamp(min(2.75rem, 12vw), 6vw + 1rem, 5.5rem);
    font-weight: var(--display-weight);
    line-height: var(--leading-tight);
    letter-spacing: var(--display-tracking);
    overflow-wrap: break-word;
    hyphens: auto;
  }

  .hero__lines { font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: var(--leading-snug); }

  .hero__cover img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    border-radius: var(--radius-xl);
    object-fit: cover;
    box-shadow: var(--shadow-raised);
  }

  .hero__wave { display: block; width: 100%; max-width: none; height: var(--space-16); margin-top: -1px; fill: var(--accent); }
  .hero__edge { display: none; fill: var(--accent); }

  /* Below the band, on the canvas: About, the card to register or the guest's ticket, then Location and Hosted by. */
  .public-page__body {
    display: grid;
    gap: var(--space-10) var(--space-16);
    align-items: start;
    max-width: calc(var(--content-width) + 2 * var(--gutter));
    margin-inline: auto;
    padding: var(--space-8) var(--gutter) var(--space-16);
  }

  .about { display: grid; gap: var(--space-5); align-content: start; max-width: 38rem; }
  .public-title, .register__title { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--tracking-heading); line-height: var(--leading-tight); }
  .public-title { font-size: var(--text-3xl); }
  .about__lead { font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-snug); letter-spacing: var(--tracking-snug); }
  .about__text { font-size: var(--text-lg); }
  .about__text + .about__text { margin-top: calc(-1 * var(--space-2)); }

  .location, .hosts { gap: var(--space-3); font-size: var(--text-lg); }
  .location__map { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius-xl); background: var(--color-surface); }
  .hosts__workspace { display: flex; gap: var(--space-3); align-items: center; justify-self: start; font-weight: var(--weight-bold); }
  .hosts__icon { width: 2.5rem; height: 2.5rem; border-radius: var(--radius-sm); object-fit: cover; }

  .register {
    --fill: var(--color-ink-8);
    --fill-hover: var(--color-ink-12);

    display: grid;
    gap: var(--space-4);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
  }

  .register__title { font-size: var(--text-3xl); }
  .register__form { display: grid; gap: var(--space-3); }
  .register__form .input { min-height: var(--control-height); }
  .register__button { width: 100%; min-height: var(--control-height-lg); margin-top: var(--space-2); font-size: var(--text-lg); }
  .register__places { font-weight: var(--weight-bold); text-align: center; }
  .register__trap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; }
  .register__sticky { display: none; }

  /* Phones reach the form from anywhere with a Register button that stays at the bottom. */
  @media (max-width: 899px) {
    .public-page__body { padding-bottom: calc(var(--control-height-lg) + var(--space-10)); }
    .register__sticky {
      position: fixed;
      inset: auto var(--gutter) var(--space-3);
      z-index: 2;
      display: flex;
      min-height: var(--control-height-lg);
      font-size: var(--text-lg);
      box-shadow: var(--shadow-float);

      &[hidden] { display: none; }
    }
  }

  .ticket { justify-items: center; text-align: center; }
  .ticket__qr { width: min(100%, 15rem); padding: var(--space-3); border-radius: var(--radius-lg); background: var(--color-surface); }
  .ticket__qr svg { width: 100%; height: auto; }
  .ticket__hint { font-weight: var(--weight-bold); }
  .ticket__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: center; }
  /* A guest opening their page at the door finds the ticket first on a phone, before About. */
  @media (max-width: 899px) { .public-page__body--ticket > .ticket { order: -1; } }

  /* The workspace's events. Timeline: each day in a column beside its row, on a dotted line. Map: the rows beside a map. */
  .agenda { grid-column: 1 / -1; display: grid; gap: var(--space-8); align-items: start; width: 100%; max-width: 60rem; margin-inline: auto; }
  .agenda__list { display: grid; gap: var(--space-4); }
  .agenda__item { --when: 9rem; --line: calc(var(--when) + var(--space-5)); position: relative; display: grid; grid-template-columns: var(--when) minmax(0, 1fr); gap: var(--space-10); }
  .agenda__item::before { content: ""; position: absolute; top: 0; bottom: calc(-1 * var(--space-4)); left: var(--line); width: 2px; background: radial-gradient(circle, var(--color-ink-12) 1px, transparent 1.5px) 0 0 / 2px 8px repeat-y; }
  .agenda__item:last-child::before { bottom: 0; }
  .agenda__item::after { content: ""; position: absolute; top: calc(var(--space-6) + 0.4rem); left: calc(var(--line) - 5px); width: 12px; height: 12px; border-radius: 50%; corner-shape: round; background: var(--color-ink); }
  .agenda__year { padding-top: var(--space-6); }
  .agenda__when { display: grid; align-content: start; padding-top: var(--space-6); font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: var(--leading-snug); }
  .agenda__when strong { font-family: var(--font-display); font-size: var(--text-xl); letter-spacing: var(--tracking-title); }
  .agenda__row { display: flex; gap: var(--space-5); align-items: center; padding: var(--space-4) var(--space-4) var(--space-4) var(--space-6); border-radius: var(--radius-xl); background: var(--color-surface); text-decoration: none; }
  .agenda__row:hover { box-shadow: var(--shadow-raised); }
  .agenda__text { display: grid; flex: 1; gap: var(--space-1); min-width: 0; font-size: var(--text-lg); }
  .agenda__title { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--display-weight); letter-spacing: var(--tracking-title); line-height: var(--leading-snug); }
  .agenda__cover { flex: none; width: 6rem; aspect-ratio: 1; border-radius: var(--radius-lg); object-fit: cover; }
  .agenda__pin { display: none; flex: none; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; corner-shape: round; background: var(--color-button); color: var(--color-on-button); font-weight: var(--weight-bold); }
  .agenda__map { display: none; margin: 0; }
  .agenda__map img { width: 100%; height: auto; aspect-ratio: 1; border-radius: var(--radius-xl); object-fit: cover; }

  /* Phones, and every row in the map layout: the day above its row, without the line. */
  [data-events-layout="map"] .agenda__item { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  [data-events-layout="map"] .agenda__item::before, [data-events-layout="map"] .agenda__item::after { display: none; }
  [data-events-layout="map"] .agenda__when { display: flex; flex-wrap: wrap; gap: 0 var(--space-2); align-items: baseline; padding: 0 var(--space-2); }
  [data-events-layout="map"] .agenda__when strong { font-size: var(--text-lg); }
  [data-events-layout="map"] .agenda__pin { display: grid; }
  [data-events-layout="map"] .agenda__map { display: block; }

  @media (min-width: 900px) {
    [data-events-layout="map"] .agenda { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); max-width: none; }
    [data-events-layout="map"] .agenda__map { position: sticky; top: var(--space-6); }
    [data-events-layout="map"] .agenda__cover { width: 4.5rem; }
  }

  @media (max-width: 767px) {
    .agenda__item { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
    .agenda__item::before, .agenda__item::after { display: none; }
    .agenda__when { display: flex; flex-wrap: wrap; gap: 0 var(--space-2); align-items: baseline; padding: 0 var(--space-2); }
    .agenda__when strong { font-size: var(--text-lg); }
    .agenda__row { padding-left: var(--space-5); }
    .agenda__title { font-size: var(--text-xl); }
    .agenda__cover { width: 4.5rem; }
    .agenda__map { order: -1; }
    [data-events-layout="map"] .agenda__cover { display: none; }
  }

  /* Bands: a wide band with the headline, the cover tilted over its wave; below, the card stays beside About, Location and Hosted by. */
  [data-theme="bands"] {
    .hero { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 1fr auto; column-gap: var(--space-12); }
    .hero__brand, .hero__title, .hero__lines { grid-column: 1; }
    .hero__title { align-self: end; margin-top: var(--space-10); }
    .hero__cover {
      position: relative;
      z-index: 1;
      grid-column: 2;
      grid-row: 1 / span 3;
      align-self: end;
      width: clamp(14rem, 24vw, 20rem);
      margin-bottom: calc(-1 * var(--space-16) - var(--space-8));
      rotate: 2deg;
    }
    .hero__lines { padding-bottom: var(--space-6); }
    .public-page__body { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); padding-top: var(--space-10); }
    .about { grid-column: 1; }
    .register { position: sticky; top: var(--space-6); grid-column: 2; grid-row: 1 / span 3; }

    /* Phones stack it all on one centred axis, as Split does, so the band lines up with the cover and the card under it. */
    @media (max-width: 767px) {
      .hero { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; justify-items: center; text-align: center; }
      .hero__brand { justify-self: center; }
      .hero__wordmark { object-position: center; }
      .hero__title { margin-top: var(--space-4); }
      .hero__lines { padding-bottom: 0; }
      .hero__cover { grid-column: 1; grid-row: auto; justify-self: center; width: min(68vw, 18rem); margin-top: var(--space-2); margin-bottom: calc(-1 * var(--space-16) - var(--space-4)); }
      .public-page__body { grid-template-columns: minmax(0, 1fr); padding-top: var(--space-8); }
      .about, .register { position: static; grid-column: auto; grid-row: auto; }
    }
  }

  /* Split: the brand's colour as a panel that stays put on the left, its edge a wave; the card, About, Location and Hosted by scroll beside it. */
  [data-theme="split"] {
    .register__form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .register__form > :not(.input) { grid-column: 1 / -1; }

    @media (min-width: 900px) {
      .public-page { display: grid; grid-template-columns: minmax(24rem, 40%) minmax(0, 1fr); }
      .hero {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 100dvh;
        gap: var(--space-6);
        padding: var(--space-10) var(--space-12) var(--space-10) max(var(--space-12), calc(50vw - 40rem));
      }
      .hero__cover { order: 1; width: min(100%, 44dvh); }
      .hero__title { order: 2; font-size: clamp(3rem, 4.5vw + 0.5rem, 5.5rem); }
      .hero__lines { order: 3; }
      .hero__edge { display: block; position: absolute; top: 0; left: calc(100% - 1px); width: var(--space-12); height: 100%; }
      .hero__wave { display: none; }
      .public-page__body { grid-template-columns: minmax(0, 1fr); max-width: 44rem; margin-inline: 0; padding: var(--space-16) var(--space-12) var(--space-16) calc(var(--space-12) + var(--space-12)); }
      .register { order: -1; }
    }

    @media (max-width: 899px) {
      .hero { justify-items: center; text-align: center; }
      .hero__brand { justify-self: center; }
      .hero__cover { order: -1; grid-row: 2; width: min(72vw, 20rem); }
      .hero__wave { height: var(--space-10); }
      .public-page__body { grid-template-columns: minmax(0, 1fr); padding-top: var(--space-4); }
      .register__form { grid-template-columns: minmax(0, 1fr); }
    }
  }

  /* The editor's preview shows a draft's form as guests will see it, but nothing in the frame does anything. */
  .public--preview :is(a, button, input, select, iframe) { pointer-events: none; }
  /* Without scripts the sticky Register never hides, so it would cover the form it points to. */
  .public--preview .register__sticky { display: none; }
}
