@font-face {
  font-family: "Patrick Hand";
  src: url("assets/patrick-hand.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #323d34;
  --muted: #6e6455;
  --page: #fbf8ef;
  --paper: #fffcf3;
  --teal: #315c52;
  --teal-dark: #25473f;
  --line: #d8cbb7;
  --hand: "Patrick Hand", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --serif: Georgia, "Times New Roman", serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='144' height='144'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23b69265' opacity='.14' filter='url(%23grain)' d='M0 0h144v144H0z'/%3E%3C/svg%3E");
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 0;
  background: var(--page);
}
button, input { font: inherit; }
button { color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #39675b;
  outline-offset: 4px;
}
p, h1, h2 { margin: 0; }
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.symbols { position: absolute; width: 0; height: 0; }
.shell { width: min(1184px, calc(100% - clamp(32px, 8vw, 112px))); margin-inline: auto; }

.photoboard-page {
  padding-top: clamp(27px, 3vw, 42px);
}
.board-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: clamp(18px, 2.6vw, 38px);
}
.board-logo {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  top: 10px;
  z-index: 1;
  width: clamp(246px, 26vw, 334px);
  margin-bottom: -18px;
  pointer-events: none;
}
.board-logo h1 { position: relative; line-height: 0; }
.board-logo img { position: relative; display: block; width: 100%; height: auto; }
.logo-backing {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 5px 7px rgb(47 38 27 / .13));
}
.logo-paper { fill: #fffdf4; }
.together-counter {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  margin-inline-end: clamp(2px, .66vw, 8px);
  text-align: center;
  white-space: nowrap;
}
.flip-clock {
  display: flex;
  justify-content: center;
  gap: .12em;
  min-height: 1.22em;
  font: 650 clamp(29px, 3.2vw, 45px)/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
.flip-digit {
  position: relative;
  display: grid;
  place-items: center;
  width: .81em;
  height: 1.22em;
  border-radius: .13em;
  background: #edf2e8;
  color: #354b42;
  box-shadow: inset 0 0 0 1px #d9e1d5, 0 2px 0 #c6d1c3, 0 4px 6px #40392a20;
}
.flip-digit::after {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline: 0;
  height: 1px;
  background: rgb(53 75 66 / .14);
}
.together-label {
  margin-top: 7px;
  font-size: clamp(12px, 1.35vw, 15px);
  font-weight: 600;
  line-height: 1.2;
}
.together-since {
  margin-top: 3px;
  color: var(--muted);
  font-size: clamp(10px, 1.2vw, 12px);
  line-height: 1.3;
}
.eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .19em;
  line-height: 1.5;
  text-transform: uppercase;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 7px 9px 7px 8px;
  font-size: 14px;
  font-weight: 720;
  line-height: 1.2;
  white-space: nowrap;
}
.primary {
  background: linear-gradient(112deg, #416c60, var(--teal) 70%);
  border-color: #254b40;
  color: #fffaf0;
  box-shadow: 0 2px 0 #214338, 0 4px 7px #3a4b3224;
}
.primary:not(:disabled):hover { background: var(--teal-dark); }
.primary:not(:disabled):active { transform: translateY(1px); box-shadow: 0 1px 0 #214338; }
.secondary { background: #fbf5e9; border-color: #d1c0a8; }
.secondary:hover { background: #f4ead9; }

.frame {
  position: relative;
  isolation: isolate;
  padding: 4px;
  margin-bottom: 26px;
}
.board-add {
  position: absolute;
  z-index: 2;
  right: clamp(14px, 1.8vw, 24px);
  bottom: clamp(14px, 1.7vw, 22px);
  width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 48% 53% 50% 47% / 47% 49% 52% 51%;
}
.board-add .icon { width: 24px; height: 24px; stroke-width: 2; }

.board-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.board-paper {
  fill: #f5ead2;
  stroke: #baa381;
  stroke-opacity: .72;
  stroke-width: 1.15;
  stroke-linejoin: round;
}
.board-viewport {
  position: relative;
  width: 100%;
  max-height: min(76svh, 780px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #bda485 transparent;
  scrollbar-width: thin;
  border-radius: 6px;
  touch-action: none;
}
.board-viewport:focus-visible { outline-offset: 3px; }
.board-surface { position: relative; width: 100%; height: 540px; overflow: hidden; }
.corkboard {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1120px;
  height: 580px;
  isolation: isolate;
  transform: scale(var(--scale, 1));
  transform-origin: top left;
  user-select: none;
}
.board-viewport.is-pannable .corkboard { cursor: grab; }
.board-viewport.is-panning .corkboard { cursor: grabbing; }

.stack {
  --pin: #a75563;
  position: absolute;
  width: 126px;
  z-index: var(--layer);
  transform: translate(-50%, -50%) rotate(var(--tilt));
}
.stack.is-dragging { z-index: 2147483646; }
.stack:focus-within { z-index: 2147483645; }
.stack[data-pin="teal"] { --pin: #47776d; }
.stack[data-pin="ochre"] { --pin: #ab7637; }
.stack[data-pin="olive"] { --pin: #667c4d; }
.stack[data-pin="brick"] { --pin: #a65542; }
.print {
  display: block;
  padding: 7px 7px 25px;
  border: 1px solid #eadcc4;
  border-radius: 2px 3px 3px 2px;
  background: var(--grain), #fffbef;
  box-shadow: 1px 2px 3px #422d1f35, 3px 6px 9px #462f242a;
}
.extra-print { position: absolute; inset: 0; background-color: #f7efde; }
.polaroid {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #39483a;
  text-align: start;
}
.front-print {
  position: relative;
  transition: box-shadow .15s ease;
}
.polaroid:hover .front-print { box-shadow: 2px 4px 4px #422d1f48, 4px 8px 12px #462f2438; }
.stack-photo {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid #65574436;
  border-radius: 1px;
  background: #d8c5a9;
}
.pushpin {
  position: absolute;
  z-index: 1;
  top: 5px;
  left: calc(50% + var(--pin-x, 0px));
  display: grid;
  place-items: center;
  width: var(--pin-target, 48px);
  height: var(--pin-target, 48px);
  transform: translate(-50%, -50%);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.pushpin:not(:disabled) { cursor: grab; }
.pushpin:disabled { pointer-events: none; }
.is-dragging .pushpin:not(:disabled) { cursor: grabbing; }
.pin-head { width: 22px; height: 22px; color: var(--pin); }

.text-button {
  min-height: 34px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: #655747;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 12px;
}
.text-button:hover { color: var(--teal-dark); }
.board-status { margin: 0 3px; color: #764b38; font-size: 13px; }
.board-status:empty { display: none; }
.board-status:not(:empty) { padding-bottom: 18px; }

.delete-notices {
  position: fixed;
  z-index: 5;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  display: grid;
  justify-items: end;
  gap: 8px;
  pointer-events: none;
}
.delete-notice {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 100%;
  padding: 6px 8px 6px 15px;
  border: 1px solid #d3bfa4;
  border-radius: 8px 10px 8px 9px;
  background: #fffaf0;
  box-shadow: 0 4px 16px #352c2430;
  font-size: 14px;
  pointer-events: auto;
}

.paper-dialog {
  width: min(100% - 30px, 465px);
  max-height: min(92svh, 760px);
  padding: 24px;
  overflow: auto;
  border: 1px solid #d3bfa4;
  border-radius: 11px 13px 10px 12px;
  background: var(--grain), #fffaf0;
  color: var(--ink);
  box-shadow: 0 14px 50px #352c2452;
}
.paper-dialog::backdrop { background: #312b235c; backdrop-filter: blur(2px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 17px; }
.dialog-heading h2 {
  margin-top: 2px;
  overflow-wrap: anywhere;
  font: 400 clamp(33px, 7vw, 43px)/1 var(--hand);
}
.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #d8c8b1;
  border-radius: 7px 8px 7px 8px;
  background: #fbf6ea;
}
.icon-button:not(:disabled):hover { background: #f0e7d7; }
fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.field-label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; }
.field-label small { margin-left: 3px; color: var(--muted); font-weight: 400; }
#caption-input, #editor-passphrase {
  width: 100%;
  min-height: 45px;
  padding: 8px 11px;
  border: 1px solid #cabbab;
  border-radius: 6px;
  background: #fffefa;
  color: var(--ink);
  font-size: 16px;
}
.file-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 85px;
  margin-top: 14px;
  padding: 13px;
  border: 1px dashed #9c947b;
  border-radius: 7px;
  background: #f5efdf;
  cursor: pointer;
}
.file-picker:hover { background: #eee8d8; }
.file-picker:focus-within { outline: 3px solid var(--teal); outline-offset: 2px; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker .icon { width: 30px; height: 27px; color: var(--teal); }
.file-picker strong { display: block; font-size: 15px; }
.file-picker small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.form-feedback { min-height: 18px; margin: 7px 0; color: #793e31; font-size: 13px; }
.form-actions { display: flex; justify-content: end; flex-wrap: wrap; gap: 8px; }
.photo-dialog { width: min(100% - 24px, 595px); }
.viewer-print {
  padding: 8px;
  background: #fffdf6;
  border: 1px solid #e4d6bd;
  box-shadow: 0 3px 7px #4d3b2920;
}
.viewer-print img {
  display: block;
  width: 100%;
  height: min(53svh, 495px);
  object-fit: contain;
  background: #eae0ce;
  touch-action: pan-y;
}
.viewer-controls { display: flex; justify-content: space-between; align-items: center; gap: 9px; margin-top: 15px; }
.viewer-controls:has(#delete-stack[hidden]) { justify-content: flex-end; }
.viewer-pagination { display: flex; align-items: center; gap: 8px; }
#viewer-count { min-width: 42px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .photoboard-page { padding-top: 24px; }
  .board-heading { grid-template-columns: minmax(0, 1fr) auto; column-gap: clamp(11px, 3.3vw, 22px); }
  .board-logo { grid-column: 1; justify-self: center; width: min(55vw, 244px); margin-bottom: -11px; }
  .together-counter { grid-column: 2; }
  .flip-clock { font-size: clamp(23px, 6.2vw, 31px); }
  .button { padding-inline: 11px; }
  .board-viewport { max-height: min(70svh, 540px); }
  .paper-dialog { padding: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
