/* Bulletins on the student's page (s/bulletins-view.js; docs/plans/
   bulletins-plan.md B1d; the Bulletins Artboard, C1 to C3). Loaded by the
   student page (s/index.html) and by the teacher's Preview as Student
   (teacher/app.html). Every rule is under .sp-view (or is the question over
   the page, .sp-bulletin-ask) and every name starts sp-bulletin-, so nothing
   here touches a screen that is not Bulletins, and no ad blocker's list
   names it (tests/fixtures/adblock-hidden-names.txt).

   The page full size is a length in the page itself, so it uses
   --sp-steady-h (s/student.css): 100vh over the zoom, which draws exactly
   the screen's height at every Text Size (a zoomed vh draws 1.3 times it at
   Larger) and does not follow iOS Safari's toolbar as it hides and shows.
   Motion: a new bulletin glides up 12 px in 200 ms; a reaction's
   colour changes in 150 ms; nothing fades in; nothing moves under Reduce
   Motion. */

/* The bottom bar with Bulletins in it, sized by StudentBulletinsView.fitTabs
   from the bar as drawn: its own width (in the page and in the preview's phone
   frame alike), the tabs actually in it, and each label's longest word. The
   tabs are equal, so the icons are evenly spaced; each label is as wide as its
   longest word, centred under its icon, and may reach past its tab but never
   into a neighbour's label or off the bar. One label size for every label,
   12 px at most. The 2 px a side are kept on the screen at every Text Size
   (divided by the zoom), so a bigger Text Size never draws the labels smaller.
   Before it has measured, the bar is s/page-view.css's. */
.sp-view .sp-tabs-bottom.sp-bulletin-tabs:has(> .sp-tab[data-tab='bulletins']) > .sp-tab {
  padding-left: var(--sp-bulletin-tab-pad, 2px);
  padding-right: var(--sp-bulletin-tab-pad, 2px);
  /* The icons in one row at the top, however many lines a label takes ("My Learning" may take two). */
  justify-content: flex-start;
  padding-top: 4px;
}
.sp-view .sp-tabs-bottom.sp-bulletin-tabs:has(> .sp-tab[data-tab='bulletins']) .sp-tab-label {
  font-size: var(--sp-bulletin-tab-font, 10px);
  /* Its width is set by fitTabs; wider than the tab, it reaches both ways. */
  flex-shrink: 0;
  text-align: center;
}

.sp-view .sp-bulletin-tab {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* The active reminder, a slim amber bar that stays under the header. */
.sp-view .sp-bulletin-pinbar {
  position: sticky;
  top: var(--sp-bulletin-under, 69px);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-height: 44px;
  margin: -16px -16px 0;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid #f0dcb8;
  background: #fff8ec;
  color: #7a4200;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.sp-view .sp-bulletin-pinbar-words {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  overflow-wrap: break-word;
}
.sp-view .sp-bulletin-pinbar-until {
  flex: none;
}
.sp-view .sp-bulletin-pin-icon {
  flex: none;
}

.sp-view .sp-bulletin-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding-top: 4px;
}
.sp-view .sp-bulletin-day {
  align-self: center;
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--sp-text-2);
}
.sp-view .sp-bulletin-new {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
  font-size: 12px;
  font-weight: 700;
  color: #c0000f;
  scroll-margin-top: 130px;
}
.sp-view .sp-bulletin-new::before,
.sp-view .sp-bulletin-new::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(215, 0, 21, 0.35);
}

/* A bulletin: the teacher's words, as a bubble from the left. */
.sp-view .sp-bulletin {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-width: 88%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 18px 18px 18px 6px;
  background: var(--sp-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  font-size: 15px;
  line-height: 1.4;
  scroll-margin-top: 130px;
  scroll-margin-bottom: 96px;
}
.sp-view .sp-bulletin:focus {
  outline: none;
}
.sp-view .sp-bulletin:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.45);
}
/* One with pages to swipe takes the width, so a page is big enough to read. */
.sp-view .sp-bulletin:has(.sp-bulletin-file) {
  width: 88%;
}
.sp-view .sp-bulletin-glide {
  animation: sp-bulletin-glide 200ms ease-out;
}
@keyframes sp-bulletin-glide {
  from {
    transform: translateY(12px);
  }
  to {
    transform: none;
  }
}
.sp-view .sp-bulletin-kind {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--sp-fill);
  color: #3a3a3c;
  font-size: 12px;
  font-weight: 600;
}
.sp-view .sp-bulletin-kind-reminder {
  background: #fff1db;
  color: #7a4200;
}
.sp-view .sp-bulletin-words {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: break-word;
}
.sp-view .sp-bulletin-time {
  align-self: flex-end;
  font-size: 11px;
  color: var(--sp-text-2);
}

/* The assignment a reminder is linked to: its card's band, and its name. */
.sp-view .sp-bulletin-piece {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--sp-line);
  border-radius: 12px;
  background: var(--sp-card);
  text-align: left;
}
.sp-view .sp-bulletin-piece .sp-band {
  margin: 0;
  border-radius: 0;
  padding: 7px 12px;
}
.sp-view .sp-bulletin-piece-title {
  display: block;
  padding: 8px 12px 10px;
  font-weight: 600;
  overflow-wrap: break-word;
}

/* A link: the site's name, and a sign that it leaves the page. */
.sp-view .sp-bulletin-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--sp-line);
  border-radius: 10px;
  background: var(--sp-card);
  text-align: left;
}
.sp-view .sp-bulletin-link-words {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.sp-view .sp-bulletin-link-title {
  font-weight: 600;
  overflow-wrap: break-word;
}
.sp-view .sp-bulletin-link-host {
  font-size: 12px;
  color: var(--sp-text-2);
  overflow-wrap: anywhere;
}
.sp-view .sp-bulletin-link-go {
  flex: none;
  color: var(--sp-blue-text);
}

/* A file's pages: one wide, 200 px tall, swiped sideways (CSS scroll-snap). */
.sp-view .sp-bulletin-file {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.sp-view .sp-bulletin-file-frame {
  position: relative;
  border: 1px solid var(--sp-line);
  border-radius: 8px;
  overflow: hidden;
  background: #eceef2;
}
.sp-view .sp-bulletin-file-track {
  display: flex;
  height: 200px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.sp-view .sp-bulletin-file-track::-webkit-scrollbar {
  display: none;
}
.sp-view .sp-bulletin-file-slide {
  flex: 0 0 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  scroll-snap-align: start;
  cursor: zoom-in;
}
.sp-view .sp-bulletin-file-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
}
.sp-view .sp-bulletin-file-count {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}
.sp-view .sp-bulletin-file-dots,
.sp-view .sp-bulletin-viewer-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
}
.sp-view .sp-bulletin-file-dot,
.sp-view .sp-bulletin-viewer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #aeaeb2;
}
.sp-view .sp-bulletin-file-dot-on,
.sp-view .sp-bulletin-viewer-dot-on {
  background: #3a3a3c;
}
.sp-view .sp-bulletin-file-name {
  margin: 0;
  font-size: 12px;
  color: var(--sp-text-2);
  overflow-wrap: break-word;
}

/* Reactions: three words, one tap, the student's own choice filled in. */
.sp-view .sp-bulletin-reacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sp-view .sp-bulletin-react {
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--sp-line);
  border-radius: 999px;
  background: var(--sp-card);
  color: #3a3a3c;
  font-size: 14px;
  font-weight: 600;
  transition:
    background-color 150ms,
    color 150ms,
    border-color 150ms;
}
.sp-view .sp-bulletin-react-on {
  border-color: #0066cc;
  background: #0066cc;
  color: #fff;
}
.sp-view .sp-bulletin-react:disabled {
  cursor: default;
}

/* A page full size, in place of the feed. */
.sp-view .sp-bulletin-viewer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.sp-view .sp-bulletin-viewer-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sp-view .sp-bulletin-viewer-back,
.sp-view .sp-bulletin-viewer-turn {
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: rgba(118, 118, 128, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sp-view .sp-bulletin-viewer-turn:disabled {
  opacity: 0.35;
  cursor: default;
}
.sp-view .sp-bulletin-viewer-next svg {
  transform: scaleX(-1);
}
.sp-view .sp-bulletin-viewer-words {
  min-width: 0;
}
.sp-view .sp-bulletin-viewer-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: break-word;
}
.sp-view .sp-bulletin-viewer-title:focus {
  outline: none;
}
.sp-view .sp-bulletin-viewer-sub {
  margin: 0;
  font-size: 13px;
  color: var(--sp-text-2);
}
.sp-view .sp-bulletin-viewer-page {
  margin: 0;
  overflow: hidden;
  border-radius: 12px;
  background: var(--sp-card);
  box-shadow: var(--sp-shadow);
}
.sp-view .sp-bulletin-viewer-img {
  display: block;
  width: 100%;
  height: auto;
  /* At most the screen's height; StudentBulletinsView.fitViewer then sets the
     real room, measured, between the header and the tab bar. */
  max-height: var(--sp-steady-h, 100vh);
  object-fit: contain;
  background: #eceef2;
}
.sp-view .sp-bulletin-viewer-wait {
  padding: 40px 16px;
}
.sp-view .sp-bulletin-viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* A class in Switch Class with "2 new" as well as "3 to do": at every Text
   Size the name and the tick hold one line and the counts go under the name,
   as s/page-view.css does for every class at Large and Larger. */
.sp-view .sp-set .sp-class:has(.sp-bulletin-class-new) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 4px;
}
.sp-view .sp-set .sp-class:has(.sp-bulletin-class-new) > .sp-class-words,
.sp-view .sp-set .sp-class:has(.sp-bulletin-class-new) > .sp-class-tick {
  grid-row: 1;
}
.sp-view .sp-set .sp-class:has(.sp-bulletin-class-new) > .sp-class-counts {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* "2 new" beside a class in Switch Class (Settings). */
.sp-view .sp-bulletin-class-new {
  flex: none;
  padding: 3px 9px;
  border-radius: 10px;
  background: #fde7e9;
  color: #b00010;
  font-size: 13px;
  font-weight: 700;
}

/* "Open this website in a new tab?" over the page (shared/website-ask.js),
   wholly above or wholly below the card that was tapped
   (StudentBulletinsView.placeAsk sets its top from the card's box). On
   <body>, outside the page and not zoomed, so its top is in the screen's own
   pixels; it takes the Text Size through --sp-zoom on each of its lengths. */
.sp-bulletin-ask-back {
  position: fixed;
  inset: 0;
  z-index: 70;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.32);
}
.sp-bulletin-ask {
  --sp-ask-z: var(--sp-zoom, 1);
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 71;
  max-width: calc(420px * var(--sp-ask-z));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: calc(6px * var(--sp-ask-z));
  padding: calc(14px * var(--sp-ask-z)) calc(16px * var(--sp-ask-z));
  border-radius: 16px;
  background: #fff;
  color: #1d1d1f;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  font-family: var(--font-base);
  font-size: calc(15px * var(--sp-ask-z));
  line-height: 1.35;
}
.sp-bulletin-ask-words {
  margin: 0;
  font-size: calc(16px * var(--sp-ask-z));
  font-weight: 700;
}
.sp-bulletin-ask-url {
  margin: 0;
  font-size: calc(13px * var(--sp-ask-z));
  color: #636366;
  overflow-wrap: anywhere;
}
/* Side by side, each taking half; a label wraps at its space rather than the
   buttons going one under the other, so the question stays short. */
.sp-bulletin-ask-buttons {
  display: flex;
  gap: calc(8px * var(--sp-ask-z));
}
.sp-bulletin-ask-go,
.sp-bulletin-ask-no {
  flex: 1 1 0;
  min-width: 0;
  min-height: calc(44px * var(--sp-ask-z));
  margin: 0;
  padding: calc(4px * var(--sp-ask-z)) calc(8px * var(--sp-ask-z));
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: calc(15px * var(--sp-ask-z));
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}
.sp-bulletin-ask-no {
  background: rgba(118, 118, 128, 0.12);
  color: #0066cc;
}
.sp-bulletin-ask-go {
  background: #0066cc;
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .sp-view .sp-bulletin-glide {
    animation: none;
  }
  .sp-view .sp-bulletin-react {
    transition: none;
  }
}
