@font-face {
  font-family: "ABC Areal";
  src: url("fonts/ABCAreal-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Turn off macOS rubber-band scrolling so the top bar never bounces */
html {
  overscroll-behavior: none;
}

body {
  font-family: "ABC Areal", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  /* Every underline sits a bit below the text; in em so it scales with the
     text size (about 4px at 17px, 6px on the 24px student names) */
  text-underline-offset: 0.25em;
}

/* --theme is the current M&M's color and --cursor a dot in that color,
   both set by shared.js. The rest are the site's colors: the page, the text
   and lines, the light gray (goals), and the top bar's background and text */
:root {
  --theme: #0073CF;
  --cursor: auto;
  --paper: #fff;
  --ink: #000;
  --muted: #999;
  --bar: #f4f4f4;
  --bar-ink: #555;
}

/* Lights off: a soft dark mode, switched by the Lights button (shared.js).
   Dark gray rather than black, with the bar a step lighter than the page,
   the same way it's a step darker with the lights on */
:root[data-lights="off"] {
  --paper: #1c1c1c;
  --ink: #e8e8e8;
  --muted: #858585;
  --bar: #2a2a2a;
  --bar-ink: #b0b0b0;
  color-scheme: dark;
}

/* The dot cursor everywhere, links and buttons included */
* {
  cursor: var(--cursor);
}

::selection {
  background: color-mix(in srgb, var(--theme) 33%, transparent);
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* ---------- Layout ---------- */

/* Content stops growing past 1440px and centers */
main {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 56px 78px 86px;
  display: grid;
  grid-template-columns: 340px 1fr auto;
  gap: 80px;
  align-items: start;
}

/* ---------- Double-line boxes ---------- */

.box {
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 4px;
  margin: 5px; /* the outline's offset + its width, so it stays inside */
  padding: 6px 12px;
}

/* ---------- Left column ---------- */

.row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.description {
  margin: 72px 0;
  font-size: 16px;
  line-height: 1.25;
  text-align: justify;
}

.description p + p {
  margin-top: 1.25em;
}

/* Goals sit in light gray; the hovered one turns black */
.goals a {
  color: var(--muted);
  transition: color 0.15s;
}

.goals a:hover {
  color: var(--ink);
}

/* ---------- Middle column ---------- */

/* The whole student row is one link */
.students a,
.instructor {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 24px;
  line-height: 42px;
}

.dot {
  display: inline-block;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transition: transform 0.15s;
}

/* Hovering a student's row or their bar dot underlines their name,
   like the other links */
.students li.highlight a {
  text-decoration: underline;
}

.instructor {
  margin-top: 30px;
  font-size: 17px;
}

.instructor a:hover {
  text-decoration: underline;
}

.instructor .email {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------- Right column ---------- */

.now {
  padding: 6px 8px;
}

.now p + p {
  margin-top: 24px;
}

#school {
  display: block;
  text-align: center;
}

#school:hover {
  text-decoration: underline;
}

/* Shuffle and Lights */
.button {
  display: block;
  width: calc(100% - 10px);
  margin-top: 24px;
  padding: 6px 8px;
  font: inherit;
  color: inherit;
  text-align: center;
  background: none;
}

.button:hover {
  text-decoration: underline;
}

/* A fixed 140 × 190 box so the column never changes width.
   script.js draws the dotted character inside it */
.mnm {
  display: block;
  width: 140px;
  height: 190px;
  margin: 24px auto 0;
}

/* Shown instead of the page if data.json can't load:
   the message, then the M&M filling the rest of the screen */
body.error {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 40px 16px;
}

.load-error {
  font-size: 24px;
  text-align: center;
}

.mnm.mnm-full {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  margin: 24px 0 0;
}

/* ---------- Top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 16px;
  /* Side padding shrinks smoothly with the window, so the bar doesn't jump between layouts */
  padding: 16px clamp(16px, 5vw, 78px);
  background: var(--bar);
  font-size: 17px;
  color: var(--bar-ink);
}

/* Set by shared.js once the bar spills onto a second row */
.bar.wrapped {
  justify-content: flex-start;
}

.bar a.link {
  text-decoration: underline;
}

.bar a.link:hover {
  text-decoration: none;
}

.bar .dot:hover,
.bar .dot.highlight {
  transform: scale(1.3);
}

/* ---------- Bulletin Board page ---------- */

/* Square previews in as many columns as fit, same margins as the home page */
.board {
  max-width: 1440px;
  margin: 0 auto;
  padding: 56px 78px 86px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 56px 40px;
}

.board a {
  display: block;
}

/* Images fit inside the square, sitting on its bottom edge */
.board-preview {
  aspect-ratio: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.board-preview img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.board-text {
  width: 100%;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--ink);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.3;
  white-space: pre-line;
}

/* A linked channel is a double-line box with its name and size */
.board-channel {
  align-self: stretch;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  text-align: center;
}

/* Titles stop after two lines, ending in "…". The line height leaves room
   for the hover underline under the second line, which the clipping would
   otherwise cut off */
.board-title {
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.board a:hover .board-title,
.board a:hover .board-channel span:first-child {
  text-decoration: underline;
}

/* The first post is a big M&M in the theme color, for adding to the board */
.board-add-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--theme);
  color: #fff;
  font-size: 64px;
  transition: transform 0.15s;
}

/* Tilts on hover, like a pinned note hanging crooked, by a random
   --tilt that bulletin.js picks each time */
.board-add:hover .board-add-dot {
  transform: rotate(var(--tilt, -15deg));
}

.board-message {
  grid-column: 1 / -1;
}

/* ---------- Desktop: each column scrolls on its own ---------- */

@media (min-width: 1101px) {
  /* The page itself stops scrolling: bar on top, columns fill the rest */
  body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  main {
    flex: 1;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    padding: 0 78px;
  }

  main > section {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none; /* hide the scrollbar, still scrollable */
    padding: 56px 0 86px;
  }

  main > section::-webkit-scrollbar {
    display: none; /* same, for older Safari */
  }

  /* On the Bulletin Board, the board below the bar is what scrolls.
     (Only here: on smaller screens the page scrolls, and a scroll box with
     nothing to scroll would swallow the wheel) */
  .board-page {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  .board-page::-webkit-scrollbar {
    display: none;
  }
}

/* ---------- Mobile: stack the columns ---------- */

@media (max-width: 1100px) {
  .board {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 40px 16px;
    padding: 44px 16px 48px;
  }

  main {
    grid-template-columns: 1fr;
    gap: 56px;
    max-width: 600px;
    margin: 0 auto;
    padding: 44px 16px 48px;
  }

  .description {
    margin: 48px 0;
  }

  .students a {
    font-size: 20px;
    line-height: 38px;
  }

  /* Weather card becomes two columns (lines fill left to right) */
  .now {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 48px;
  }

  .now p + p {
    margin-top: 0;
  }

  /* Character box stretches to the full width, keeping its 140 × 190 shape */
  .mnm {
    width: 100%;
    height: auto;
    aspect-ratio: 140 / 190;
  }
}
