/* Notes board: a galvanized steel sheet with printed notes on it.
   Sizes follow Board's Mac app (github.com/susiesyli/board) in CSS px. The sheet is
   always 1200 x 750 and board.js scales it to fit, so a note sits in the same place
   on every screen. Below 640 px the sheet becomes a plain column of notes. */

.notes-board-page {
  --nb-ink: #1b1b1c;
  --nb-print: rgba(26, 26, 26, .72);
  --nb-print-2: rgba(26, 26, 26, .48);
  --nb-emboss: 0 .8px 0 rgba(255, 255, 255, .55);
  --nb-font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --nb-mono: "SF Mono", ui-monospace, Menlo, monospace;
}

/* The tracing paper's look. On localhost, press D on the board for sliders; "Save"
   rewrites this block (tools/notes-board-tune/server.mjs). Editing by hand is fine too. */
/* tune:start */
.notes-board-page {
  --tp-tint: .22;
  --tp-blur: 3.5px;
  --tp-lift: 1.2;
  --tp-sat: .3;
  --tp-edge: .7;
  --tp-shadow: .05;
  --tp-width: 204px;
  --tp-pad: 16px;
  --tp-gap: 9px;
  --tp-marks: .5;
  --tp-mark-size: 7px;
  --tp-font: var(--nb-mono);
  --tp-size: 9px;
  --tp-leading: 1.55;
  --tp-tracking: .25px;
  --tp-case: none;
  --tp-ink: .92;
  --tp-pill: 1;
  --tp-photo-width: 224px;
  --tp-overlap: 0%;
  --tp-photo-gap: 8px;
  --tp-inset: 0px;
}
/* tune:end */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.nb-page {
  display: flex;
  justify-content: center;
  /* the nav is fixed over the page; clear it as the other pages do */
  padding: 72px 24px 40px;
}

/* Takes the sheet's scaled size, since a transform doesn't move layout. */
.nb-frame {
  position: relative;
  flex: none;
  width: 1200px;
  height: 750px;
}

/* -- the metal ------------------------------------------------------------- */

.nb-sheet {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1200px;
  height: 750px;
  overflow: hidden;
  transform-origin: 0 0;
  border-radius: 1px;
  font-family: var(--nb-font);
  background:
    /* daylight from above, washing out the top of the sheet */
    radial-gradient(circle 520px at 30% 0, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0)),
    linear-gradient(rgba(255, 255, 255, .3) 0, rgba(255, 255, 255, .1) 30%, rgba(255, 255, 255, 0) 60%, rgba(0, 0, 0, .1) 100%),
    /* zinc's cool cast */
    linear-gradient(rgba(107, 128, 153, .16), rgba(107, 128, 153, .16)),
    url(steel.jpg) 0 0 / 512px 800px repeat #999;
  /* the cut edge, and the sheet's own shadow on the page */
  box-shadow:
    0 0 0 .5px rgba(0, 0, 0, .12),
    0 1px 2px rgba(0, 0, 0, .1),
    0 14px 40px -8px rgba(0, 0, 0, .22);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.nb-scratches {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* -- small print on the metal ------------------------------------------------ */

.nb-hint,
.nb-status,
.nb-under {
  font: 500 7.5px/1.4 var(--nb-font);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.nb-hint,
.nb-status,
.nb-under {
  color: var(--nb-print);
  text-shadow: var(--nb-emboss);
}

.nb-hint {
  position: absolute;
  top: 16px;
  left: 18px;
  z-index: 1;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Desktop: off the board until a keyboard user tabs to it. */
.nb-hint.is-quiet:not(:focus-visible) {
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.nb-hint:hover,
.nb-hint:focus-visible {
  color: rgba(10, 10, 10, .92);
}

.nb-hint:focus-visible {
  outline: .7px solid currentColor;
  outline-offset: 3px;
}

.nb-status {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 1;
  margin: 0;
}

.nb-status button,
.nb-under button {
  margin: 0 0 0 10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-shadow: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: .5px;
  text-underline-offset: 2px;
}

/* -- notes ------------------------------------------------------------------- */

.nb-notes {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nb-note {
  position: absolute;
  width: var(--tp-width);
  transform: translate(-50%, -50%);
}

/* The card: a photo (if any) and a leaf of tracing paper. It only carries the lift. */
.nb-paper {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  color: var(--nb-ink);
  transition: transform .28s cubic-bezier(.3, 1.4, .5, 1);
}

/* Frosted tracing paper. It lifts what's underneath rather than painting over it,
   so another note's words or a photo below still show through as soft grey. */
.nb-leaf {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--tp-gap);
  padding: var(--tp-pad);
  background: rgba(250, 250, 250, var(--tp-tint));
  backdrop-filter: blur(var(--tp-blur)) saturate(var(--tp-sat)) brightness(var(--tp-lift));
  -webkit-backdrop-filter: blur(var(--tp-blur)) saturate(var(--tp-sat)) brightness(var(--tp-lift));
  outline: .5px solid rgba(255, 255, 255, var(--tp-edge));
  outline-offset: -.5px;
  box-shadow: 0 .5px 1px rgba(0, 0, 0, var(--tp-shadow));
  transition: box-shadow .2s ease-out;
}

/* Crop marks in the four corners: printed, so they don't read as buttons. */
.nb-leaf::after {
  --c: rgba(27, 27, 28, var(--tp-marks));
  --m: var(--tp-mark-size);
  --h: calc(var(--tp-mark-size) / 2);
  content: "";
  position: absolute;
  inset: 5px;
  pointer-events: none;
  background:
    linear-gradient(var(--c), var(--c)) left 0 top var(--h) / var(--m) .7px,
    linear-gradient(var(--c), var(--c)) left var(--h) top 0 / .7px var(--m),
    linear-gradient(var(--c), var(--c)) right 0 top var(--h) / var(--m) .7px,
    linear-gradient(var(--c), var(--c)) right var(--h) top 0 / .7px var(--m),
    linear-gradient(var(--c), var(--c)) left 0 bottom var(--h) / var(--m) .7px,
    linear-gradient(var(--c), var(--c)) left var(--h) bottom 0 / .7px var(--m),
    linear-gradient(var(--c), var(--c)) right 0 bottom var(--h) / var(--m) .7px,
    linear-gradient(var(--c), var(--c)) right var(--h) bottom 0 / .7px var(--m);
  background-repeat: no-repeat;
}

.nb-note.is-lifted .nb-paper {
  transform: scale(1.03);
}

/* Sliding clear of another note after being let go. */
.nb-note.is-settling {
  transition: left .32s cubic-bezier(.2, .8, .2, 1), top .32s cubic-bezier(.2, .8, .2, 1);
}

.nb-note.is-lifted .nb-leaf,
.nb-note.is-lifted .nb-photo {
  box-shadow: 0 2px 2px rgba(0, 0, 0, .14), 4px 12px 14px rgba(0, 0, 0, .24);
}

.nb-note.is-movable {
  cursor: grab;
  touch-action: none;
}

.nb-note.is-lifted {
  cursor: grabbing;
}

.nb-text {
  margin: 0;
  color: rgba(27, 27, 28, var(--tp-ink));
  font: 400 var(--tp-size) / var(--tp-leading) var(--tp-font);
  letter-spacing: var(--tp-tracking);
  text-transform: var(--tp-case);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The writer's name (or "Anonymous") in an outlined pill. */
.nb-pill {
  align-self: flex-start;
  box-sizing: border-box;
  max-width: 100%;
  margin: 0;
  padding: 2px 6px 1.5px;
  border: .7px solid rgba(27, 27, 28, var(--tp-pill));
  border-radius: 999px;
  color: rgba(27, 27, 28, var(--tp-ink));
  font: 400 7.5px/1 var(--tp-font);
  letter-spacing: .5px;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A photo or GIF: the print stays sharp, its tracing-paper caption laid over the
   lower part, where the photo goes soft. */
.nb-note.has-image {
  width: var(--tp-photo-width);
}

.nb-note.has-image .nb-leaf {
  margin: calc(var(--tp-photo-gap) - var(--tp-overlap)) var(--tp-inset) 0;
}

.nb-photo {
  display: block;
  width: 100%;
  object-fit: cover;
  background: rgba(31, 31, 33, .08);
  box-shadow: 0 .5px .4px rgba(0, 0, 0, .2), .6px 1.2px 2px rgba(0, 0, 0, .07);
  pointer-events: none;
  transition: box-shadow .2s ease-out;
}

/* A file dragged over the metal. */
.nb-sheet.is-drop::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 20000;
  border: 1px dashed rgba(255, 255, 255, .8);
  pointer-events: none;
}

/* Writing a note: the same card, with the type set straight onto the paper. */
.nb-note.is-editing {
  z-index: 10000 !important;
  cursor: auto;
}

textarea.nb-text,
input.nb-pill {
  display: block;
  box-sizing: border-box;
  background: none;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

textarea.nb-text {
  width: 100%;
  padding: 0;
  border: 0;
  resize: none;
  overflow: hidden;
}

/* The name field is the pill itself, sized to what's typed. */
input.nb-pill {
  field-sizing: content;
  min-width: 9ch;
}

textarea.nb-text::placeholder,
input.nb-pill::placeholder {
  color: rgba(27, 27, 28, .38);
}

/* Small print under a card, on the metal. */
.nb-under {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  width: max-content;
  max-width: 260px;
  margin: 0;
}

.nb-under:empty {
  display: none;
}

/* Owner's controls and confirmations: a small dark capsule attached to the card. */
.nb-capsule {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1;
  display: flex;
  gap: 10px;
  align-items: center;
  height: 20px;
  padding: 0 9px;
  border-radius: 10px;
  background: #1a1a1a;
  color: #fff;
  font: 500 7.5px/1 var(--nb-font);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, .25);
}

.nb-capsule button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  opacity: .75;
}

.nb-capsule button:hover,
.nb-capsule button:focus-visible {
  opacity: 1;
}

.nb-capsule .is-danger {
  color: rgb(255, 140, 128);
  opacity: 1;
}

/* Shown on hover. It lingers a moment after the pointer leaves, so reaching for it
   from the card never loses it. */
.nb-note .nb-capsule.on-hover {
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease-out .25s, visibility 0s linear .4s;
}

.nb-note:hover .nb-capsule.on-hover,
.nb-note:focus-within .nb-capsule.on-hover {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

/* An invisible bridge over the gap between card and capsule, so moving the pointer
   down from one to the other stays a hover. */
.nb-capsule::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 8px;
}

/* Hidden notes, shown to the owner only: out of focus, like Board's done items.
   (On the leaf and photo, not the card: a filter on the card would cut the leaf
   off from the metal it frosts.) */
.nb-note.is-hidden .nb-leaf,
.nb-note.is-hidden .nb-photo {
  filter: blur(1.6px);
  opacity: .45;
  transition: filter .2s ease-out, opacity .2s ease-out;
}

.nb-note.is-hidden:hover .nb-leaf,
.nb-note.is-hidden:hover .nb-photo {
  filter: none;
  opacity: .55;
}

.nb-turnstile {
  margin-top: 8px;
}

.nb-noscript {
  font: 400 13px/1.5 var(--nb-font);
}

/* -- phones: a column of notes, newest first ---------------------------------- */

.nb-frame.is-stack {
  width: 100%;
  max-width: 420px;
  height: auto;
}

.nb-frame.is-stack .nb-sheet {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 70vh;
  transform: none;
  padding: 40px 18px 48px;
  box-sizing: border-box;
}

.nb-frame.is-stack .nb-notes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
}

.nb-frame.is-stack .nb-note {
  position: relative;
  left: auto !important;
  top: auto !important;
  z-index: auto !important;
  width: min(100%, 280px);
  transform: none;
}

.nb-frame.is-stack .nb-compose:not(:empty) {
  display: flex;
  justify-content: center;
  margin-bottom: 52px;
}

.nb-frame.is-stack .nb-paper {
  width: 100%;
}

.nb-frame.is-stack .nb-text {
  font-size: calc(var(--tp-size) * 1.3);
}

.nb-frame.is-stack .nb-under {
  max-width: 100%;
}

@media (max-width: 640px) {
  .nb-page {
    /* the phone nav is in the page flow, so nothing to clear */
    padding: 8px 12px 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nb-paper,
  .nb-note.is-settling {
    transition: none;
  }
}
