/* The gallery (2026-10-25): /gallery and /gallery/<slug>, on top of site.css and
   public.css. On the gallery the figures sit on the page itself — no boards
   behind them (USER REQUEST: "we don't need background boards"); on the dark
   theme they are drawn in light ink, as the chat draws a figure without its
   board (gallery.js). A problem's own page keeps its figure on a board — white
   paper in every theme (USER REQUEST: "the individual problem pages should
   have board"). The gallery's Board switch (USER REQUEST, same day: "have a
   board option in the gallery page, if the board on then have board under each
   diagram") puts the same white paper under every card's figure: the root's
   class g-boards, set before the first paint from compas.gallery.board. */
@font-face { font-family: "CMU Serif"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/cmunserif-regular.woff2") format("woff2"); }
@font-face { font-family: "CMU Serif"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("/static/fonts/cmunserif-italic.woff2") format("woff2"); }
@font-face { font-family: "CMU Serif"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/cmunserif-bold.woff2") format("woff2"); }

/* ---- a figure: the static picture, then the live one in the same box ---- */
.g-paper { display: flex; flex-direction: column; align-items: center; justify-content: center; }
/* the figure's stage (the card's figure area; the problem's board above its
   tools): the box is the printed picture itself, at most at its printed width —
   no blank room round it (USER REPORT 2026-10-25: the room a figure keeps for
   its points to move into "makes the actual diagram small"); what moves past
   the picture is drawn over the stage (live.js opts.roomSpill), clipped at its
   edge, and a dragged point stays inside it. The player's "?" sits in its corner. */
.g-stage { position: relative; overflow: hidden; }
.g-stage:hover > .egml-live-help-btn { opacity: .85; }
.g-stage > .egml-live-help { max-height: calc(100% - 36px); overflow: auto; }
.g-box { position: relative; aspect-ratio: var(--ar); margin: 0 auto; flex: none; }
.g-box.anim { margin-bottom: 34px; }                 /* the ▶ ↺ bar under the drawing */
.g-box img.g-static { position: absolute; left: 0; top: 0; width: 100%; height: auto; max-width: none; display: block; -webkit-user-select: none; user-select: none; }
/* until something moves the print shows and the live layer only takes the
   pointer (its locus lies under the print's ink); from the first move the live
   figure draws — as in the chat's Move */
.g-box.is-live:not(.is-pristine) img.g-static { visibility: hidden; }
.g-box svg.egml-live.pristine .egml-ink, .g-box svg.egml-live.pristine .egml-labels { visibility: hidden; }
:root:not([data-theme="dark"]) .g-box.is-pristine .g-live svg.egml-live,
.g-board .g-box.is-pristine .g-live svg.egml-live,
.g-boards .g-card .g-box.is-pristine .g-live svg.egml-live { mix-blend-mode: multiply; }
/* the dark theme before the exact light ink is in: an approximation (the print
   inverted, its hues kept) — gallery.js puts the chat's own ink in its place */
:root[data-theme="dark"]:not(.g-boards) .g-paper:not(.g-board) .g-box img.g-static:not(.inked) { filter: invert(0.9) hue-rotate(180deg); }
/* the player's own controls, on the dark page */
:root[data-theme="dark"]:not(.g-boards) .g-paper:not(.g-board) .egml-live-bar button { background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
:root[data-theme="dark"]:not(.g-boards) .g-paper:not(.g-board) .egml-live-help-btn { background: var(--panel); color: var(--muted); border-color: var(--line-strong); }
:root[data-theme="dark"]:not(.g-boards) .g-paper:not(.g-board) .egml-live-help { background: var(--panel); color: var(--ink-soft); border-color: var(--line-strong); }
:root[data-theme="dark"]:not(.g-boards) .g-paper:not(.g-board) .egml-live-help-head b,
:root[data-theme="dark"]:not(.g-boards) .g-paper:not(.g-board) .egml-live-help li b { color: var(--ink); }
.g-box .g-live { position: absolute; left: 0; top: 0; width: 100%; }
.g-box .g-live .egml-live-wrap { display: block; width: 100%; }
.g-box .g-live svg.egml-live { width: 100%; height: auto; max-width: none; }
.g-box.is-busy .g-live { opacity: .55; transition: opacity .15s; }
.g-box .egml-live-bar { padding-left: 0; }

/* ---- the Effects menu (the chat's items) ---- */
.g-tools { display: flex; align-items: center; justify-content: flex-end; min-height: 30px; }
.g-fxwrap { position: relative; }
.g-fxbtn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; font: 500 13px/1 "Instrument Sans", system-ui, sans-serif;
  color: var(--ink-soft); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; white-space: nowrap; }
.g-fxbtn:hover, .g-fxbtn[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.g-fxbtn svg { width: 15px; height: 15px; flex: none; }
.g-fxmenu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: max-content; min-width: 240px; max-width: min(320px, 86vw);
  padding: 6px; background: var(--panel); border-radius: 12px; box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-lg); }
.g-fxmenu[hidden] { display: none; }
.g-fxhead { font: 600 11px/1 "Instrument Sans", system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 8px 10px 6px; }
.g-fxsep { height: 1px; background: var(--line); margin: 6px 4px; }
.g-fxmenu button { display: grid; grid-template-columns: 18px 1fr; column-gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); text-align: left; cursor: pointer; font: 14px/1.3 "Instrument Sans", system-ui, sans-serif; }
.g-fxmenu button:hover:not(:disabled), .g-fxmenu button:focus-visible { background: var(--hover); outline: none; }
.g-fxmenu button:disabled { color: var(--faint); cursor: default; }
.g-fxmenu .mk { grid-row: span 2; align-self: start; margin-top: 2px; width: 14px; height: 14px; border: 1.5px solid var(--line-strong); }
.g-fxmenu [role="menuitemradio"] .mk { border-radius: 50%; }
.g-fxmenu [role="menuitemcheckbox"] .mk { border-radius: 4px; }
.g-fxmenu [aria-checked="true"] .mk { border-color: var(--strong); background: var(--strong); box-shadow: inset 0 0 0 2.5px var(--panel); }
.g-fxmenu [role="menuitemcheckbox"][aria-checked="true"] .mk { box-shadow: none;
  background: var(--strong) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3.5 7.2l2.3 2.3 4.7-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat; }
:root[data-theme="dark"] .g-fxmenu [role="menuitemcheckbox"][aria-checked="true"] .mk {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3.5 7.2l2.3 2.3 4.7-5' fill='none' stroke='%2312181C' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.g-fxmenu .note { grid-column: 2; font-size: 12.5px; color: var(--muted); }

/* ---- the gallery page ---- */
.g-intro { margin: 0 0 36px; }
.g-introhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
/* the Board switch: the chat's own switch, in the Effects button's frame */
.g-boardsw { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 9px; flex: none;
  font: 500 13px/1 "Instrument Sans", system-ui, sans-serif; color: var(--ink-soft); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; white-space: nowrap; }
.g-boardsw:hover { background: var(--hover); color: var(--ink); }
.g-boardsw[hidden] { display: none; }
.g-boardsw .sw { width: 26px; height: 16px; border-radius: 999px; position: relative; flex: none;
  background: var(--line-strong); transition: background .15s; }
.g-boardsw .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 999px; background: #FFFFFF; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: left .15s; }
.g-boardsw[aria-pressed="true"] .sw { background: var(--accent); }
.g-boardsw[aria-pressed="true"] .sw::after { left: 12px; }
.g-intro .lead { max-width: 70ch; }
/* two problems a row (USER REQUEST 2026-10-25), one on a narrow screen */
.g-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 56px 48px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-card { display: flex; flex-direction: column; min-width: 0; }
.g-card .g-paper { height: 420px; padding: 8px 0; }
.g-card .g-box { --fh: 400px; width: min(100%, var(--w), calc(var(--fh) * var(--ar))); }
.g-card .g-box.anim { --fh: 366px; }
/* Board on: the card's figure area is white paper, the figure inside its margin */
.g-boards .g-card .g-paper { padding: 16px; border-radius: 14px; background: #FFFFFF; box-shadow: 0 0 0 1px var(--line), var(--shadow-lg); }
.g-boards .g-card .g-box { --fh: 388px; }
.g-boards .g-card .g-box.anim { --fh: 354px; }
.g-body { display: flex; flex-direction: column; flex: 1; padding: 14px 2px 0; border-top: 1px solid var(--line); }
.g-body h3 { margin: 0; font-size: 17px; line-height: 1.3; letter-spacing: -0.005em; }
.g-body h3 a { color: var(--ink); text-decoration: none; }
.g-body h3 a:hover { color: var(--accent); }
.g-body .g-sub { margin: 3px 0 0; font-size: 14px; line-height: 1.4; color: var(--muted); }
.g-excerpt { margin: 10px 0 0; font-family: "CMU Serif", "Latin Modern Roman", Georgia, serif; font-size: 15.5px; line-height: 1.55;
  color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.g-excerpt .katex { font-size: 1em; }
.g-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 14px; }
.g-actions .g-tools { justify-content: flex-start; }
.g-actions .g-fxmenu { left: 0; right: auto; }
.g-open { font-size: 14px; font-weight: 500; color: var(--ink-soft); text-decoration: none; padding: 6px 2px; white-space: nowrap; }
.g-open:hover { color: var(--accent); }
.g-cta { margin: 64px 0 0; padding: 28px; border-radius: 14px; background: var(--panel); box-shadow: 0 0 0 1px var(--line); text-align: center; }
.g-cta h2 { margin: 0 0 6px; }
.g-cta p { margin: 8px auto 0; color: var(--muted); max-width: 60ch; }
.g-cta .btn { margin-top: 10px; }

/* ---- a problem's own page ---- */
.g-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; padding: 0; font-size: 13px; color: var(--faint); }
.g-crumbs li + li::before { content: "›"; margin-right: 6px; color: var(--faint); }
.g-crumbs a { color: var(--muted); text-decoration: none; }
.g-crumbs a:hover { color: var(--ink); }
.g-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 44px; align-items: start; }
.g-figcol { position: sticky; top: 76px; }
.g-paper.big { margin: 0; }
.g-paper.big .g-box { width: min(100%, var(--w), calc(74vh * var(--ar))); }
/* the problem's board: white paper in every theme; the figure's stage runs to
   its edges, the tools below it */
.g-paper.g-board { padding: 0; border-radius: 16px; background: #FFFFFF; box-shadow: 0 0 0 1px var(--line), var(--shadow-lg); }
.g-board .g-stage { align-self: stretch; padding: 22px 22px 0; border-radius: 16px 16px 0 0; }
.g-board .g-stage > .egml-live-help-btn { top: 2px; right: 2px; }
.g-paper.g-board .g-tools { align-self: stretch; padding: 10px 22px 22px; }
:root[data-theme="dark"] .g-board .g-fxbtn { background: #FFFFFF; color: #3C4851; border-color: rgba(36, 49, 58, 0.18); }
:root[data-theme="dark"] .g-board .g-fxbtn:hover, :root[data-theme="dark"] .g-board .g-fxbtn[aria-expanded="true"] { background: #F4F4F4; color: #24313A; }
.g-text h1 { font-size: 30px; margin: 0; }
.g-sub { margin: 6px 0 0; font-size: 17px; color: var(--muted); line-height: 1.45; }
.g-text h2 { font-size: 13px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin: 30px 0 10px; }
.g-statement { margin: 0; font-family: "CMU Serif", "Latin Modern Roman", Georgia, serif; font-size: 17.5px; line-height: 1.62; color: var(--ink);
  white-space: pre-line; font-kerning: normal; font-variant-ligatures: common-ligatures; }
.g-statement .katex { font-size: 1em; }
.g-source { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.g-source .k { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-right: 6px; }
.g-howto { margin: 0; font-size: 14.5px; color: var(--ink-soft); }
.g-cta-line { margin: 22px 0 0; }
.g-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 48px 0 0; }
.g-pager a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 12px; text-decoration: none;
  background: var(--panel); box-shadow: 0 0 0 1px var(--line); color: var(--ink); }
.g-pager a:hover { box-shadow: 0 0 0 1px var(--line-strong); }
.g-pager .next { text-align: right; }
.g-pager .k { font-size: 12.5px; color: var(--faint); }
.g-pager .t { font-weight: 500; }
.g-back { margin: 28px 0 0; font-size: 14px; }
.g-back a { color: var(--muted); text-decoration: none; }
.g-back a:hover { color: var(--ink); }

@media (max-width: 960px) {
  .g-layout { grid-template-columns: 1fr; gap: 26px; }
  .g-figcol { position: static; }
  .g-paper.big .g-box { width: min(100%, var(--w), calc(70vh * var(--ar))); }
}
@media (max-width: 780px) {
  .g-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .g-paper.g-board { border-radius: 12px; }
  .g-board .g-stage { padding: 20px 12px 0; border-radius: 12px 12px 0 0; }
  .g-board .g-stage > .egml-live-help-btn { top: 1px; right: 1px; }
  .g-paper.g-board .g-tools { padding: 10px 12px 12px; }
  .g-card .g-paper { height: 320px; padding: 6px 0; }
  .g-card .g-box { --fh: 308px; }
  .g-card .g-box.anim { --fh: 274px; }
  .g-boards .g-card .g-paper { padding: 12px; border-radius: 12px; }
  .g-boards .g-card .g-box { --fh: 296px; }
  .g-boards .g-card .g-box.anim { --fh: 262px; }
  .g-grid { gap: 44px; }
  .g-text h1 { font-size: 25px; }
  .g-pager { grid-template-columns: 1fr; }
  .g-pager .next { text-align: left; }
}

/* ---- phones (USER REQUEST 2026-10-26: "the design of gallery … in both modes") ---- */
@media (max-width: 560px) {
  .g-intro { margin-bottom: 26px; }
  .g-intro h1 { font-size: 30px; }
  .g-intro .lead { font-size: 15.5px; margin-bottom: 0; }
  .g-grid { gap: 0; }
  .g-card { padding: 22px 0 26px; border-top: 1px solid var(--line); }
  .g-card:first-child { border-top: 0; padding-top: 0; }
  .g-card .g-paper { height: auto; min-height: 220px; padding: 4px 0 10px; }
  .g-body { border-top: 0; padding-top: 6px; }
  .g-body h3 { font-size: 18px; }
  .g-excerpt { font-size: 16px; -webkit-line-clamp: 4; }
  .g-actions { padding-top: 12px; }
  .g-open { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 14px; border-radius: 10px;
    background: var(--strong); color: var(--on-strong); font-size: 14px; }
  .g-open:hover { color: var(--on-strong); filter: brightness(1.1); }
  .g-fxbtn { height: 36px; padding: 0 12px; border-radius: 10px; }
  .g-cta { margin-top: 36px; padding: 24px 18px; }
  /* a problem's page: the board runs to the screen's edges, so the figure gets the width */
  .g-problem .g-crumbs ol { margin-bottom: 12px; }
  .g-paper.g-board { margin: 0 -16px; border-radius: 0; box-shadow: 0 1px 0 var(--line), 0 -1px 0 var(--line); }
  .g-board .g-stage { padding: 16px 10px 0; border-radius: 0; }
  .g-paper.g-board .g-tools { padding: 8px 12px 12px; }
  .g-text h1 { font-size: 26px; }
  .g-statement { font-size: 17px; }
  .g-pager { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 36px; }
  .g-pager .next { text-align: right; }
  .g-pager a { padding: 12px 14px; }
  .g-pager .t { font-size: 14px; }
}
