/* ==========================================================================
   PIC Spotlight posters

   Shared by every spotlight page. Like pic.css, it is written for plain
   semantic HTML with no <div> or <span> hooks: decorations are drawn with
   pseudo-elements, and each talk is laid out with a CSS grid on its own
   <section class="talk">.

   Colours are the UCLA palette used on www.pic.ucla.edu. Every text colour
   below is quoted with its contrast ratio against the poster background
   (SC 1.4.3 needs 4.5:1 for normal text; SC 1.4.11 needs 3:1 for
   meaningful graphics).
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* UCLA palette (same values as pic.css) */
  --darker-blue: #005587;
  --darkest-blue: #003b5c;
  --lighter-blue: #8bb8ee;
  --lightest-blue: #daebfe;
  --ucla-gold: #ffd100;
  --gray-05: #f2f2f2;

  /* Roles                                     contrast on --poster-bg */
  --poster-bg: var(--darkest-blue);
  --text: #fff;                             /* 11.80:1 */
  --text-soft: var(--lightest-blue);        /*  9.72:1 */
  --accent: var(--ucla-gold);               /*  8.07:1 */
  --trace: var(--lighter-blue);             /*  5.72:1 (decorative only) */

  --font: Helvetica, Roboto, Arial, "Lucida Grande", sans-serif;

  --poster-width: 66rem;
  --pad: clamp(1rem, 4vw, 3rem);

  /* Decorative circuit traces. The SVGs are drawn with overflow past their
     viewBox, so with background-size: 100% 100% and preserveAspectRatio
     "meet" the nodes keep their shape while the lines run on to the edge of
     whatever box they are painted in. The traces only ever sit in boxes of
     their own, never behind text, so they cannot reduce text contrast. */
  --trace-in: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 100' preserveAspectRatio='xMaxYMid meet'%3E%3Cg fill='none' stroke='%238bb8ee' stroke-width='3' stroke-linejoin='round'%3E%3Cpath vector-effect='non-scaling-stroke' d='M-4000 60H100L140 20H230'/%3E%3Cpath vector-effect='non-scaling-stroke' d='M-4000 76H106.6L146.6 36H282'/%3E%3Cpath vector-effect='non-scaling-stroke' d='M-4000 92H113.2L153.2 52H202'/%3E%3C/g%3E%3Cg fill='%23ffd100'%3E%3Ccircle cx='236' cy='20' r='7'/%3E%3Ccircle cx='289' cy='36' r='8'/%3E%3Ccircle cx='205' cy='52' r='5'/%3E%3C/g%3E%3C/svg%3E");
  --trace-out: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 100' preserveAspectRatio='xMinYMid meet'%3E%3Cg fill='none' stroke='%238bb8ee' stroke-width='3' stroke-linejoin='round'%3E%3Cpath vector-effect='non-scaling-stroke' d='M70 20H160L200 60H4300'/%3E%3Cpath vector-effect='non-scaling-stroke' d='M18 36H153.4L193.4 76H4300'/%3E%3Cpath vector-effect='non-scaling-stroke' d='M98 52H146.8L186.8 92H4300'/%3E%3C/g%3E%3Cg fill='%23ffd100'%3E%3Ccircle cx='64' cy='20' r='7'/%3E%3Ccircle cx='11' cy='36' r='8'/%3E%3Ccircle cx='95' cy='52' r='5'/%3E%3C/g%3E%3C/svg%3E");

  /* Event detail icons, used as masks so they take their colour from CSS. */
  --icon-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 6.5V12l3.5 2'/%3E%3C/svg%3E");
  --icon-pin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s7-6.6 7-12.5a7 7 0 0 0-14 0C5 15.4 12 22 12 22z'/%3E%3Ccircle cx='12' cy='9.5' r='2.5'/%3E%3C/svg%3E");
}


/* --------------------------------------------------------------------------
   2. Base

   The <body> is the poster: a fixed-measure panel that fills small screens
   and sits on a light surround on large ones.

   Font sizes are in rem so they follow the reader's text size (SC 1.4.4).
   The few headings that also scale with the viewport never have a maximum
   more than 2.5 times their minimum, which keeps them zoomable to 200%.
   -------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  background-color: var(--gray-05);
}

body {
  max-width: var(--poster-width);
  margin: 0 auto;
  padding: var(--pad);
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--poster-bg);
}

@media (min-width: 70rem) {
  body {
    margin-block: 2rem;
  }
}

/* A single long word must not push the page sideways at 320px wide or at
   400% zoom (SC 1.4.10). */
h1,
h2,
p,
li {
  overflow-wrap: break-word;
}

h1,
h2 {
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}


/* --------------------------------------------------------------------------
   3. Header

   Small screens: a band of circuit traces above the right-aligned title.
   Wide screens: the traces run in from the left edge of the poster and end
   beside the title, as on the printed poster.
   -------------------------------------------------------------------------- */

header {
  display: grid;
  grid-template-areas:
    "trace"
    "pic"
    "title";
  justify-items: end;
  text-align: end;
  margin-block-end: 1.5rem;
}

header::before {
  content: "";
  grid-area: trace;
  justify-self: stretch;
  height: 3rem;
  margin-block-end: 1rem;
  margin-inline-start: calc(-1 * var(--pad));
  background: var(--trace-in) center / 100% 100% no-repeat;
}

.pic {
  grid-area: pic;
  margin: 0 0 0.75rem;
  padding-block-end: 0.25rem;
  border-block-end: 0.1875rem solid currentColor;
  font-size: clamp(1rem, 0.75rem + 1.25vw, 1.625rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.event_title {
  grid-area: title;
  margin: 0;
  font-size: clamp(2.5rem, 1rem + 5vw, 4.5rem);
  line-height: 1;
}

@media print, (min-width: 48rem) {
  header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "trace pic"
      "trace title";
    column-gap: 1.5rem;
  }

  header::before {
    height: auto;
    margin-block-end: 0;
  }
}


/* --------------------------------------------------------------------------
   4. Event details
   -------------------------------------------------------------------------- */

.event_details ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.event_details li {
  position: relative;
  padding-inline-start: 1.75em;
  font-size: 1.25rem;
}

.event_details li + li {
  margin-block-start: 0.5rem;
}

/* The icons repeat what the text already says, so they are decorative and
   empty content keeps them silent for screen readers. They still meet 3:1
   (gold, 8.07:1) so they read clearly. */
.event_details li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.15em;
  width: 1.25em;
  height: 1.25em;
  background-color: var(--accent);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.time {
  --icon: var(--icon-clock);
}

.location {
  --icon: var(--icon-pin);
}

.event_details::after {
  content: "";
  display: none;
  min-height: 4.5rem;
  margin-inline-end: calc(-1 * var(--pad));
  background: var(--trace-out) center / 100% 100% no-repeat;
}

@media print, (min-width: 48rem) {
  .event_details {
    display: grid;
    grid-template-columns: auto minmax(6rem, 1fr);
    column-gap: 2rem;
    align-items: center;
  }

  .event_details::after {
    display: block;
  }
}


/* --------------------------------------------------------------------------
   5. Talks

   Small screens: one column in source order (title, speakers, images,
   abstract).

   Wide screens and print, default: title and speakers across the top, then the
   abstract on the left with the image beside it on the right.

   Wide screens and print with a banner image (img.banner): the banner, title,
   speakers and abstract stack on the left and the other image sits on the
   right, top-aligned with the banner. The last row is 1fr so that, if the
   right-hand image is ever the taller column, the extra height goes below
   the abstract rather than opening gaps between the headings.
   -------------------------------------------------------------------------- */

.talk {
  margin-block-start: 3rem;
}

.talk_title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.625rem);
  color: var(--accent);
}

.speaker,
.speakers {
  margin: 0 0 1rem;
  color: var(--text);
}

.speakers {
  padding: 0;
  list-style: none;
}

.abstract {
  margin: 0;
  color: var(--text-soft);
}

.talk > img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-block: 1.5rem;
}

@media print, (min-width: 48rem) {
  .talk {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "title    title"
      "speaker  speaker"
      "abstract side";
    column-gap: 2.5rem;
    align-items: start;
  }

  .talk_title {
    grid-area: title;
  }

  .speaker,
  .speakers {
    grid-area: speaker;
  }

  .abstract {
    grid-area: abstract;
  }

  .talk > img {
    grid-area: side;
    align-self: center;
    width: 100%;
    margin: 0;
  }

  .talk:has(> .banner) {
    grid-template-areas:
      "banner   side"
      "title    side"
      "speaker  side"
      "abstract side";
    grid-template-rows: auto auto auto 1fr;
  }

  .talk:has(> .banner) > img {
    align-self: start;
  }

  .talk > .banner {
    grid-area: banner;
    margin-block-end: 1.5rem;
  }
}


/* --------------------------------------------------------------------------
   6. Closing traces
   -------------------------------------------------------------------------- */

main::after {
  content: "";
  display: block;
  height: 4rem;
  margin-block-start: 3rem;
  margin-inline: 35% calc(-1 * var(--pad));
  background: var(--trace-out) center / 100% 100% no-repeat;
}


/* --------------------------------------------------------------------------
   7. Preferences and print
   -------------------------------------------------------------------------- */

/* Windows High Contrast and other forced-colour modes replace background
   colours, which would erase the masked icons. Paint them in the system
   text colour instead. */
@media (forced-colors: active) {
  .event_details li::before {
    forced-color-adjust: none;
    background-color: CanvasText;
  }
}

/* Print the poster as it looks on a wide screen: same colours, same
   two-column layout, on a single sheet.

   Browsers normally drop background colours and images when printing,
   which would leave white text on white paper. print-color-adjust: exact
   (an inherited property, so it is set once on the root) asks them to keep
   the navy background, the masked icons and the circuit traces.

   A letter or A4 page is narrower than the 48rem breakpoint, so every
   two-column rule above is also applied to print explicitly.

   The page margin is zero so the navy reaches the edge of the sheet; the
   body's padding provides the margin instead, and --pad keeps the traces
   running to the edge. (Most printers cannot print the outermost few
   millimetres, so a thin white border may remain on paper.)

   To fit the whole poster on one letter or A4 sheet, the type size and
   line height are tightened and the image column is narrower than on
   screen. These only affect paper (SC 1.4.4 concerns text on screen). If a future poster has longer abstracts and
   spills onto a second page, lower the html font-size here a little. */
@media print {
  @page {
    margin: 0;
  }

  :root {
    --pad: 0.4in;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html {
    font-size: 8.25pt;
    background-color: var(--poster-bg);
  }

  body {
    max-width: none;
    margin: 0;
    line-height: 1.35;
  }

  header {
    margin-block-end: 0.75rem;
  }

  /* The image column is narrower than on screen (1 : 1.3). That shortens
     the images and widens the abstracts, which frees the height for a
     clear gap above each talk. */
  .talk {
    margin-block-start: 2.75rem;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    column-gap: 1.5rem;
    break-inside: avoid;
  }

  .speaker,
  .speakers {
    margin-block-end: 0.6rem;
  }

  .talk > .banner {
    margin-block-end: 1rem;
  }

  /* As on the Canva poster, the closing traces sit in the empty space below
     the right-hand column, level with the end of the last abstract, rather
     than taking a row of their own. If a future poster's right-hand image
     runs right down to the bottom, set display: none here instead. */
  main {
    position: relative;
  }

  main::after {
    position: absolute;
    bottom: 0;
    left: calc((100% - 1.5rem) * 1.3 / 2.3 + 1.5rem); /* start of the right-hand column; keep in step with .talk above */
    right: calc(-1 * var(--pad));
    height: 3rem;
    margin: 0;
  }
}
