/* Room chrome styling: the uploader component, image buttons, the editing
   island, the image drawer, and the modal menus. Form styling comes from the
   vendored lustre_ui stylesheet (see priv/static/vendor/lustre-ui/); buttons
   are `.st-img-button` below. */

/* Site font: Drafting Mono (OFL, priv/static/fonts/drafting-mono/). Absolute
   URLs — this sheet is also adopted into the server-component shadow root as a
   constructed stylesheet, where relative URLs would resolve against the page. */
@font-face {
  font-family: "Drafting Mono";
  src: url("/static/fonts/drafting-mono/DraftingMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Drafting Mono";
  src: url("/static/fonts/drafting-mono/DraftingMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Drafting Mono";
  src: url("/static/fonts/drafting-mono/DraftingMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Wins over lustre-ui's :root definitions on source order. */
:root {
  --font-base: "Drafting Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  --font-mono: var(--font-base);
}

/* lustre-ui only ships .font-base/.font-mono utility classes — nothing applies
   a site-wide font, so set it here; it inherits into the shadow root. */
body {
  font-family: var(--font-base);
}

scraptable-uploader {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.st-uploader-hint {
  margin: 0;
  color: oklch(45% 0.02 250);
}

.st-uploader-status {
  margin: 0;
  min-height: 1.25em;
  color: oklch(45% 0.02 250);
}

.st-uploader-download {
  color: oklch(50% 0.18 250);
  font-weight: 600;
}

/* Browse image-button + chosen-file name, one row. */
.st-uploader-file {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.st-uploader-file-name {
  color: oklch(45% 0.02 250);
}

/* Conversion/upload spinner. Sizing + the `scraptable-spin` keyframes come from
   table.css's `.scraptable-spinner`; this just centers it in the column. */
.st-uploader-spinner {
  align-self: center;
}

.st-uploader-spinner[hidden] {
  display: none;
}

/* Image buttons: chrome-less <button> around an <img> whose art comes from
   /static/images/buttons/<name>.png (see the README there). Gray tint + border
   on hover, darker while pressed, dimmed while disabled. */
.st-img-button {
  display: inline-block; /* uniform box for <button> and <a> alike */
  padding: 0;
  border: 2px solid transparent;
  background: none;
  cursor: pointer;
  line-height: 0;
}

.st-img-button img {
  display: block;
  height: 5rem;
  width: auto;
}

.st-img-button:hover {
  background: rgb(128 128 128 / 0.18);
  border-color: gray;
}

.st-img-button:active {
  background: rgb(128 128 128 / 0.35);
}

.st-img-button:active img {
  filter: brightness(0.75);
}

.st-img-button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Floating panels wear drop-in 9-slice art (see images/backgrounds/README):
   the PNG's outer 48px ring maps onto a 24px border, the middle fills the
   panel. A missing PNG falls back to the transparent border + each panel's
   flat background underneath. border-image ignores border-radius — rounded
   corners belong in the art. */
.scraptable-menu-box,
.st-island,
.st-drawer {
  border: 24px solid transparent;
}

.scraptable-menu-box {
  border-image: url("/static/images/backgrounds/menu.png") 48 fill / 24px;
}

.scraptable-menu-box .st-img-button img {
    height: 3rem;
}

.scraptable-menu-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.scraptable-menu-box .scraptable-menu-close img {
  height: 1.5rem;
}

.st-island {
  border-image: url("/static/images/backgrounds/island.png") 48 fill / 24px;
}

.st-drawer {
  border-image: url("/static/images/backgrounds/drawer.png") 48 fill / 24px;
  border-bottom-width: 0; /* flush with the screen's bottom edge */
}

/* Editing island: the bottom-center toolbar of scrap tools while editing
   with a selection (a chrome item, so positioning comes from table.css).
   Two rows: z-order controls on top, link + copy beneath. */
.st-island {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0rem;
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.st-island-row {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
}

.st-island .st-img-button img {
  height: 3rem;
}

/* Image drawer — slides up from the bottom edge in editing mode. Always in
   the DOM so the transform can transition; closed it sits fully offscreen
   (no invisible band stealing pointer events from OSD). The bottom chrome
   rides up via `st-drawer-open` rules in css/table.css, which also defines
   --st-drawer-height. */
.st-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--st-drawer-height);
  box-sizing: border-box;
  padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
  z-index: 1500; /* above chrome (1000), below the modal menus (10000) */
  background: white;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.st-drawer.open {
  transform: translateY(0);
}

/* A vertically scrolling grid: the upload tile, then image tiles. Tiles aim
   for 5rem squares; the clamp keeps the column count between 2 (narrow
   phones) and 6 (wide screens). */
.st-drawer-strip {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(clamp(calc((100% - 5.5rem) / 10), 10dvh, calc((100% - 0.5rem) / 2)), 1fr)
  );
  gap: 0.5rem;
  height: 100%;
  align-content: start;
  overflow-y: auto;
  overflow-x: hidden;
}

.st-drawer-add,
.st-drawer-tile {
  aspect-ratio: 1;
}

.st-drawer-add img {
  height: 100%;
  width: 100%;
  object-fit: contain;
}

.st-drawer-tile {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 0.5rem;
  background: none;
  cursor: pointer;
}

.st-drawer-hint {
  grid-column: 1 / -1;
  align-self: center;
  margin: 0;
  padding: 0 0.5rem;
  color: oklch(45% 0.02 250);
}

scraptable-thumb {
  display: block;
  width: 100%;
  height: 100%;
}

scraptable-thumb canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.st-drawer-tile:hover {
  background: rgb(128 128 128 / 0.18);
  border-color: gray;
}

.st-drawer-tile:active {
  background: rgb(128 128 128 / 0.35);
}

/* Modal "pause menu": full-screen grayed scrim + centered box. Rendered as a
   sibling of <scraptable-table>, above chrome (1000) and the loader (9999). */
.scraptable-menu {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
}

.scraptable-menu-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.scraptable-menu-box {
  position: relative; /* a centered grid item, above the scrim */
  z-index: 1;
  max-width: min(90vw, 28rem);
  max-height: 85dvh;
  overflow: auto;
  padding: 1.25rem;
  border-radius: 0.75rem;
  background: white;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}


/* Full-screen notice shown instead of the table (not authorized / log in). */
.st-notice {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
}

/* Settings panel content (inside the modal box or the full-screen notice). */
.st-settings {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 16rem;
  text-align: left;
}
.st-settings h2 {
  margin: 0.5rem 0 0;
  font-size: 1.1rem;
}
.st-settings form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.st-settings label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
}
/* Don't stretch image buttons across the flex-column forms. */
.st-settings .st-img-button {
  align-self: flex-start;
}
.st-form-error {
  color: oklch(55% 0.2 25);
  margin: 0;
}
.st-profile {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
}
.st-profile dt { font-weight: 600; }
.st-profile dd { margin: 0; }
.st-swatch {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 25%;
  vertical-align: -0.15em;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

/* The settings room list: the link grows, the admin buttons stay small. */
.st-rooms {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.st-rooms li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.st-rooms li a {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.st-rooms .st-img-button img {
  height: 1.5rem;
}

/* The room-settings member list: who grows, the controls stay small. */
.st-members {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.st-members li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.st-members .st-member-who {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.st-members .st-img-button img {
  height: 1.5rem;
}

/* The auth forms when they ARE the page (no role, not logged in). */
.st-auth-page {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: 22rem;
  width: 100%;
  margin: 0 auto;
}
