/* Potato Patch Kids: a one-bit HyperCard stack. Two colors exist. */

@font-face {
  font-family: "Pixelify Sans";
  src: url("assets/fonts/PixelifySans.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --ink: #000;
  --paper: #fff;
  --chicago: "Pixelify Sans", Chicago, "Lucida Console", monospace;
  --geneva: Geneva, Verdana, Tahoma, sans-serif;
  --monaco: Monaco, "Lucida Console", Consolas, monospace;
  /* dither patterns, drawn as 1-bit SVG tiles */
  --dot12: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Crect width='4' height='4' fill='%23fff'/%3E%3Crect width='1' height='1' fill='%23000'/%3E%3C/svg%3E");
  --dot25: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2' shape-rendering='crispEdges'%3E%3Crect width='2' height='2' fill='%23fff'/%3E%3Crect width='1' height='1' fill='%23000'/%3E%3C/svg%3E");
  --dot50: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2' shape-rendering='crispEdges'%3E%3Crect width='2' height='2' fill='%23fff'/%3E%3Crect width='1' height='1' fill='%23000'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23000'/%3E%3C/svg%3E");
  --dot75: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2' shape-rendering='crispEdges'%3E%3Crect width='2' height='2' fill='%23000'/%3E%3Crect width='1' height='1' fill='%23fff'/%3E%3C/svg%3E");
  --stripes: repeating-linear-gradient(to bottom, #000 0 1px, #fff 1px 2px);
  --card-w: 640px;
  --card-h: 420px;
  --zoom: 1;
  color-scheme: light only;
}

* { box-sizing: border-box; }
html { background: var(--ink); }
html, body { margin: 0; height: 100%; }
body {
  font: 13px/1.45 var(--geneva);
  color: var(--ink);
  background: var(--paper) var(--dot50);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection { background: var(--ink); color: var(--paper); }
a { color: inherit; }
b, strong { font-weight: 700; }
img { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
kbd { font: inherit; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- desktop and menubar ---------- */
.desktop {
  height: 100%;
  display: grid;
  grid-template-rows: 20px 1fr;
}
.menubar {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: stretch;
  height: 20px;
  padding: 0 0 0 8px;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
  font-family: var(--chicago);
  font-size: 15px;
  font-weight: 500;
  line-height: 19px;
  user-select: none;
}
.menu { position: relative; }
.mtitle { height: 19px; padding: 0 9px; white-space: nowrap; }
.mtitle-icon { padding: 0 8px; }
.mtitle .glyph { width: 16px; height: 16px; vertical-align: -3px; fill: var(--ink); }
.menu.open .mtitle { background: var(--ink); color: var(--paper); }
.menu.open .mtitle .glyph { fill: var(--paper); }
.mtitle:focus-visible { outline: 1px dotted var(--ink); outline-offset: -2px; }
.dropdown {
  display: none;
  position: absolute;
  top: 20px; left: 0;
  margin: 0; padding: 2px 0;
  list-style: none;
  min-width: 200px;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.menu.open .dropdown { display: block; }
.dropdown li { margin: 0; }
.dropdown .sep { height: 1px; margin: 3px 0; background: var(--dot25); }
.dropdown [role^="menuitem"] {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0 14px 0 8px;
  height: 19px;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.dropdown [role^="menuitem"] kbd { margin-left: auto; padding-left: 20px; }
.dropdown [role^="menuitem"]:hover,
.dropdown [role^="menuitem"]:focus-visible { background: var(--ink); color: var(--paper); outline: 0; }
.dropdown .chk { display: inline-block; width: 14px; }
.dropdown [aria-checked="true"] .chk::before { content: "\2713"; }
.mstatus {
  margin-left: auto;
  padding: 0 10px;
  font-family: var(--geneva);
  font-size: 11px;
  line-height: 19px;
}
.mstatus [data-live] { font-size: 12px; }

/* ---------- stage ---------- */
.stage {
  display: grid;
  place-content: center;
  grid-auto-rows: max-content;
  justify-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 10px;
}
.window {
  width: calc(var(--card-w) + 16px);
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 1px 1px 0 var(--ink);
  zoom: var(--zoom);
}
.titlebar {
  position: relative;
  height: 19px;
  border-bottom: 1px solid var(--ink);
  background: var(--stripes);
  background-clip: content-box;
  padding: 3px 0;
  user-select: none;
}
.closebox {
  position: absolute;
  left: 8px; top: 3px;
  width: 13px; height: 13px;
  background: var(--paper);
  border: 1px solid var(--ink);
  outline: 1px solid var(--paper);
}
.closebox:active { background: var(--ink); }
.closebox:focus-visible { outline: 1px dotted var(--ink); outline-offset: 2px; }
.wtitle {
  position: absolute;
  left: 50%; top: 0;
  transform: translateX(-50%);
  margin: 0;
  padding: 0 8px;
  font: 500 15px/19px var(--chicago);
  background: var(--paper);
  white-space: nowrap;
}
.cardhost {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  margin: 6px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 7px 5px 8px 6px / 5px 8px 6px 7px;
  background: var(--paper);
}

/* ---------- cards ---------- */
.card {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 10px 12px 12px;
  background: var(--paper);
}
.card.current { display: flex; }
.cardtitle {
  margin: 0 0 10px;
  padding: 2px 8px 1px;
  font: 600 17px/22px var(--chicago);
  background: var(--ink);
  color: var(--paper);
  letter-spacing: 0;
}
.cardtitle .dim { font: 700 12px/22px var(--geneva); margin-left: 10px; }
.num, .counts b, .mstatus [data-live], .navpos, .rec .rnum { font-family: var(--geneva); font-weight: 700; }
.code { font-family: var(--monaco); font-weight: 700; }
.cardbody { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cardbody.cols { flex-direction: row; gap: 18px; }
.cardbody.cols .col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cardbody.center { align-items: center; text-align: center; justify-content: center; gap: 8px; }
.cardbody p { margin: 0 0 8px; }
.cardbody p:last-child { margin-bottom: 0; }
.display {
  font: 700 30px/1.05 var(--chicago);
  margin: 0 0 8px;
}
.display.big { font-size: 34px; margin-top: 6px; }
.quote { font-weight: 700; }
.lead { margin-bottom: 4px; }
.pic { margin: 0; flex: none; }
.pic img { border: 1px solid var(--ink); }
.pic figcaption { margin-top: 4px; font-size: 11px; }
.list, .steps { margin: 0 0 8px; padding-left: 18px; }
.list li, .steps li { margin: 0 0 3px; }
.list li::marker { content: "\25A0  "; font-size: 9px; }
.steps li { margin-bottom: 7px; }
.counts { font-family: var(--chicago); font-size: 14px; }
.counts b { font-size: 15px; }
.hint { font-size: 11px; margin-top: auto; }
.fine { font-size: 11px; }
.credit { font-size: 11px; margin-top: 8px; }
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 14px;
  margin: 0 0 8px;
}
.facts.wide { grid-template-columns: 70px 1fr; }
.facts dt { font-family: var(--chicago); font-size: 14px; font-weight: 500; line-height: 19px; }
.facts dd { margin: 0; }
.link { text-decoration: underline; font: inherit; }
.lead.small { font: 500 14px/1.2 var(--chicago); margin: 6px 0 4px; }

/* stack index on the home card */
.index { list-style: none; margin: 4px 0 0; padding: 0; columns: 2; column-gap: 12px; }
.index li { break-inside: avoid; margin: 0 0 3px; }
.ilink { font: 500 14px/18px var(--chicago); text-align: left; padding-left: 14px; position: relative; }
.ilink::before { content: ""; position: absolute; left: 1px; top: 5px; width: 8px; height: 8px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M1 0h1v1h1v1h1v1h1v1h1v1h-1v1h-1v1h-1v1h-1v1H1z' fill='%23000'/%3E%3C/svg%3E") no-repeat; image-rendering: pixelated; }
.ilink:hover, .ilink:focus-visible { background: var(--ink); color: var(--paper); outline: 0; }
.ilink:hover::before, .ilink:focus-visible::before { filter: invert(1); }

/* picks: small linked records */
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 2px 0 8px; }
.picks.row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick { display: flex; gap: 8px; text-decoration: none; min-width: 0; align-items: flex-start; }
.picks.row .pick { flex-direction: row; gap: 6px; }
.pick img { flex: none; width: 96px; height: 54px; border: 1px solid var(--ink); }
.picks.row .pick img { width: 64px; height: 36px; }
.picks.row .ptitle { font-size: 11px; -webkit-line-clamp: 2; }
.picks.row .pmeta { font-size: 10px; }
.pick .pt { display: flex; flex-direction: column; min-width: 0; }
.pick .ptitle { font-size: 12px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pick .pmeta { font-size: 11px; margin-top: 1px; }
.pick:hover .ptitle { text-decoration: underline; }
.pick:focus-visible { outline: 1px dotted var(--ink); outline-offset: 3px; }

/* the games field */
.fieldbox { border: 1px solid var(--ink); padding: 10px 12px 8px; }
.fieldbox .checks { grid-template-columns: 1fr 1fr; gap: 7px 10px; margin: 0 0 10px; }
.otherrow { display: flex; align-items: center; gap: 8px; margin: 0; }
.otherlabel { font: 500 14px/1 var(--chicago); white-space: nowrap; }
.otherrow .input { max-width: 240px; }
.pic.side { width: 160px; margin-top: 2px; }
.pic.side .tally { margin-top: 8px; font-size: 13px; line-height: 1.3; }

/* join card */
.joinbox { align-items: center; justify-content: center; text-align: center; gap: 6px; flex: 0 0 272px !important; border-left: 1px solid var(--ink); padding-left: 18px; }
.display.mid { font-size: 26px; line-height: 1.1; margin: 0; }
.joinbox .counts { margin: 4px 0 2px; line-height: 1.35; }
.joinbox .hint { margin-top: 2px; }

/* keys column on the about card */
.keys { flex: 0 0 250px !important; border-left: 1px solid var(--ink); padding-left: 18px; }
.keymap { grid-template-columns: max-content 1fr; gap: 3px 10px; font-size: 12px; margin-bottom: 4px; }
.keymap dt { font-size: 13px; }
kbd { font: 500 12px/14px var(--chicago); border: 1px solid var(--ink); border-radius: 3px; padding: 0 4px; display: inline-block; min-width: 18px; text-align: center; }

/* buttons: HyperCard round rects */
.btnrow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-top: auto;
  padding-top: 8px;
}
.btnrow.right { justify-content: flex-end; margin-top: 12px; }
.btn {
  display: inline-block;
  padding: 4px 16px 3px;
  min-width: 96px;
  font: 500 15px/20px var(--chicago);
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 7px;
  white-space: nowrap;
  user-select: none;
}
.btn.default { position: relative; }
.btn.default::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 3px solid var(--ink);
  border-radius: 11px;
  pointer-events: none;
}
.btn.huge { padding: 10px 40px 8px; font-size: 22px; margin: 8px 0 10px; }
.btn.huge.default::after { inset: -7px; border-width: 4px; border-radius: 15px; }
.btn:active, .btn.pressed { background: var(--ink); color: var(--paper); }
.btn:focus-visible { outline: 1px dotted var(--ink); outline-offset: 9px; }
.btn.default:focus-visible { outline-offset: 9px; }
.btn.disabled, .btn[aria-disabled="true"] { color: transparent; background: var(--dot25); pointer-events: none; }

/* checkboxes */
.checks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px 12px;
  margin: 4px 0 8px;
}
.check { display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  flex: none;
  width: 13px; height: 13px;
  border: 1px solid var(--ink);
  background: var(--paper);
  position: relative;
}
.check input:checked + .box::before,
.check input:checked + .box::after {
  content: "";
  position: absolute;
  left: 5px; top: -1px;
  width: 1px; height: 13px;
  background: var(--ink);
  transform: rotate(45deg);
}
.check input:checked + .box::after { transform: rotate(-45deg); }
.check input:focus-visible + .box { outline: 1px dotted var(--ink); outline-offset: 2px; }
.tally { font-family: var(--chicago); font-size: 14px; }

/* video records */
.recs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 12px;
}
.rec {
  display: block;
  text-decoration: none;
  min-width: 0;
}
.rec img { width: 100%; height: auto; border: 1px solid var(--ink); }
.rec .rtitle {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.3;
  min-height: 2.6em;
}
.rec .rmeta { display: block; font-size: 11px; margin-top: 2px; }
.rec .rnum { font-size: 11px; }
.rec:hover .rtitle { text-decoration: underline; }
.rec:focus-visible { outline: 1px dotted var(--ink); outline-offset: 3px; }

/* edit mode */
body.editing [data-field] {
  outline: 1px dashed var(--ink);
  outline-offset: 3px;
  background: var(--dot12);
  cursor: text;
}
body.editing [data-field]:focus { outline-style: solid; background: var(--paper); }
body.editing .cardtitle::after { content: " (editing)"; font-weight: 400; font-size: 13px; }

/* canvases */
.paint, .dissolve {
  position: absolute;
  inset: 0;
  width: var(--card-w);
  height: var(--card-h);
  image-rendering: pixelated;
  pointer-events: none;
}
.paint { z-index: 5; }
.dissolve { z-index: 6; display: none; }
body[data-tool="pencil"] .paint,
body[data-tool="spray"] .paint,
body[data-tool="eraser"] .paint { pointer-events: auto; cursor: crosshair; }

/* nav bar */
.navbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 1px 1px 0 var(--ink);
  zoom: var(--zoom);
  user-select: none;
}
.navbtn {
  width: 34px; height: 24px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  display: grid;
  place-items: center;
}
.navbtn .glyph { width: 16px; height: 16px; fill: var(--ink); }
.navbtn:active { background: var(--ink); }
.navbtn:active .glyph { fill: var(--paper); }
.navbtn:focus-visible { outline: 1px dotted var(--ink); outline-offset: 2px; }
.navbtn[aria-disabled="true"] { background: var(--dot25); pointer-events: none; }
.navbtn[aria-disabled="true"] .glyph { opacity: 0.35; }
.navpos { font: 700 13px/1 var(--geneva); min-width: 60px; text-align: center; }
.navjoin { width: auto; padding: 0 12px 0 8px; gap: 6px; grid-auto-flow: column; font: 500 15px/1 var(--chicago); text-decoration: none; margin-left: 6px; }
.navjoin .glyph { width: 14px; height: 14px; }

/* dialogs */
.dialog-backdrop {
  position: fixed; inset: 0;
  z-index: 50;
  background: transparent;
}
.dialog {
  position: fixed;
  z-index: 60;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px));
  padding: 14px 16px 16px;
  background: var(--paper);
  border: 2px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 3px;
  box-shadow: 4px 4px 0 var(--ink);
}
.dialog.wide { width: min(560px, calc(100vw - 32px)); }
.dialog h3 { margin: 0 0 10px; font: 600 17px/1.2 var(--chicago); }
.dlg-note { margin: 8px 0 0; font-size: 12px; }
.input {
  width: 100%;
  padding: 4px 6px;
  font: 14px/1.3 var(--geneva);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
}
.input:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.script {
  margin: 0;
  max-height: 50vh;
  overflow: auto;
  padding: 8px 10px;
  font: 12px/1.5 var(--monaco);
  border: 1px solid var(--ink);
  white-space: pre;
  scrollbar-color: var(--ink) var(--paper);
}
.script::-webkit-scrollbar { width: 15px; height: 15px; }
.script::-webkit-scrollbar-track { background: var(--dot25); border-left: 1px solid var(--ink); }
.script::-webkit-scrollbar-thumb { background: var(--paper); border: 1px solid var(--ink); }
.script::-webkit-scrollbar-corner { background: var(--paper); }
.minis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.mini {
  display: block;
  padding: 0;
  text-align: left;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  overflow: hidden;
}
.mini .mt { display: block; padding: 2px 5px; font: 500 12px/16px var(--chicago); background: var(--ink); color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .mb { display: block; height: 34px; padding: 3px 5px; font-size: 9px; line-height: 1.2; overflow: hidden; background: var(--dot12); }
.mini.now { outline: 2px solid var(--ink); outline-offset: 1px; }
.mini:focus-visible { outline: 1px dotted var(--ink); outline-offset: 3px; }
.mini:active .mb { background: var(--dot50); }

/* ---------- phones ---------- */
@media (max-width: 719px) {
  :root { --card-w: 100%; --card-h: auto; --zoom: 1 !important; }
  body { overflow: auto; }
  .desktop { height: auto; min-height: 100%; grid-template-rows: 20px auto; }
  .menubar { position: sticky; top: 0; padding-left: 2px; }
  .mtitle { padding: 0 7px; font-size: 14px; }
  .mstatus { display: none; }
  .stage { padding: 12px 12px 24px; display: block; }
  .window { width: 100%; }
  .cardhost { width: auto; height: auto; }
  .navbar { flex-wrap: wrap; }
  .navjoin { flex-basis: 100%; margin: 6px 0 0; height: 30px; justify-content: center; }
  .pic.side { width: 100%; display: flex; gap: 12px; align-items: center; }
  .pic.side img { width: 90px; height: 90px; }
  .pic.side .tally { margin: 0; }
  .card { position: relative; inset: auto; min-height: 0; padding: 10px 12px 14px; }
  .cardbody.cols { flex-direction: column; gap: 12px; }
  .pic img { width: 150px; height: 150px; }
  .pic.small img { width: 120px; height: 120px; }
  .display { font-size: 26px; }
  .display.mid { font-size: 22px; }
  .joinbox, .keys { flex: 1 1 auto !important; border-left: 0; padding-left: 0; border-top: 1px solid var(--ink); padding-top: 12px; }
  .index { columns: 1; }
  .picks { grid-template-columns: 1fr; }
  .picks.row { grid-template-columns: 1fr 1fr; }
  .checks { grid-template-columns: 1fr 1fr; }
  .recs { grid-template-columns: 1fr 1fr; }
  .btnrow { margin-top: 10px; }
  .btn { padding: 6px 16px 5px; }
  .btn.huge { padding: 10px 24px 8px; font-size: 20px; }
  .hint { margin-top: 10px; }
  .navbar { width: 100%; margin-top: 12px; justify-content: center; }
  .paint, .dissolve { width: 100%; height: 100%; }
  .minis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 400px) {
  .checks { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .dissolve { display: none !important; }
}
