@font-face { font-family: Drafting; src: url(fonts/drafting.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Fell; src: url(fonts/fell.woff2) format("woff2"); font-display: swap; }
:root { --paper: #efe7d6; --card: #f3ecdd; --ink: #2a211b; --red: #b8402a; --pencil: #9c9184; --card-w: clamp(214px, 20vw, 290px); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); font-family: Drafting, cursive; -webkit-tap-highlight-color: transparent; }
body {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(239, 231, 214, 0) 55%, rgba(110, 82, 46, .24) 100%),
    url(img/paper.jpg) 0 0 / 512px 512px repeat,
    var(--paper);
}
button { font: inherit; color: inherit; cursor: pointer; }
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; }
.red { color: var(--red); }

/* the tools, inked tabs in the corner */
#tools { position: fixed; top: 12px; right: 14px; display: flex; gap: 6px; z-index: 4; }
#tools button { background: rgba(243, 236, 221, .9); border: 1.2px solid var(--ink); border-radius: 1px; padding: 5px 10px 4px;
  font-size: 13px; text-transform: uppercase; letter-spacing: .1em; }
#tools button:hover { background: #e9dfca; }
#bSound.off { color: var(--pencil); text-decoration: line-through; }

/* the title block, the stamp on an architect's sheet */
#tb { position: fixed; right: 16px; bottom: 16px; width: clamp(200px, 17vw, 250px); z-index: 2; text-align: center;
  background: url(img/paper.jpg) 0 0 / 512px repeat, var(--paper); border: 1.5px solid var(--ink);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4.2px var(--ink); padding: 11px 12px 9px; }
.tbTitle { font-family: Fell, Georgia, serif; font-size: 25px; line-height: 1.05; }
.tbSub { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; margin-top: 3px; }
.tbGrid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1.2px solid var(--ink); border-bottom: 1.2px solid var(--ink); margin: 8px -12px 0; }
.tbGrid > div { padding: 6px 4px 5px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.tbGrid > div + div { border-left: 1.2px solid var(--ink); }
.tbGrid b { display: block; font-family: Fell, Georgia, serif; font-weight: 400; font-size: 30px; line-height: 1.05; letter-spacing: 0; }
.tbRow { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1.2px solid var(--ink); margin: 0 -12px; padding: 5px 12px 4px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.tbRow b { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62%; }
.tbMotto { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #5b5048; margin-top: 7px; }
#stamp { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%) rotate(-13deg); border: 3px double var(--red); color: var(--red);
  font-family: Fell, Georgia, serif; font-size: 19px; line-height: 1.1; padding: 4px 10px 3px; text-transform: uppercase; white-space: nowrap;
  opacity: .85; mix-blend-mode: multiply; pointer-events: none; background: rgba(239, 231, 214, .25); }
#stamp small { display: block; font-family: Drafting, cursive; font-size: 12px; letter-spacing: .1em; }
#stamp.fresh { animation: stampIn .32s ease-out; }
@keyframes stampIn { from { opacity: 0; transform: translate(-50%, -50%) rotate(-13deg) scale(1.7); } to { opacity: .85; transform: translate(-50%, -50%) rotate(-13deg) scale(1); } }

/* the scale: height and weight against things everybody knows */
.scale { margin: 0 -12px; border-bottom: 1.2px solid var(--ink); text-align: left; }
.scItem { padding: 5px 12px 5px; }
.scItem + .scItem { border-top: 1px dashed rgba(42, 33, 27, .45); }
.scTop { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.scTop b { font-family: Fell, Georgia, serif; font-weight: 400; font-size: 19px; letter-spacing: 0; text-transform: none; }
.scC { font-size: 13px; line-height: 1.2; color: var(--red); margin-top: 1px; }
.scBar { height: 4px; border: 1px solid var(--ink); margin: 4px 0 2px; position: relative; }
.scBar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ink); transition: width .6s; }
.scN { font-size: 10.5px; letter-spacing: .04em; color: #3f5f2e; line-height: 1.2; }
/* the specification card clipped to the sheet */
#cardWrap { position: fixed; left: 14px; top: 16px; width: var(--card-w); z-index: 3; }
#clip { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 64px; z-index: 2; pointer-events: none;
  filter: drop-shadow(1px 2px 1px rgba(42, 33, 27, .3)); }
#card { margin-top: 22px; max-height: calc(100vh - 54px); overflow-y: auto; scrollbar-width: thin;
  background: url(img/paper.jpg) 120px 80px / 512px repeat, var(--card); border: 1.5px solid var(--ink);
  box-shadow: 3px 4px 0 rgba(42, 33, 27, .13); padding: 30px 14px 12px; display: flex; flex-direction: column; gap: 6px; }
#card h2 { margin: 0; text-align: center; font-family: Drafting, cursive; font-weight: 400; font-size: 22px; letter-spacing: .1em; text-transform: uppercase; }
#card h3 { margin: 2px 0 0; font-weight: 400; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; }
.tabs { display: flex; justify-content: center; gap: 4px; }
.tabs button { background: none; border: 0; border-bottom: 1.5px solid transparent; padding: 2px 6px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--pencil); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button.na { text-decoration: line-through; }
.arrowRule { height: 10px; flex: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='10'%3E%3Cpath d='M7 1.5 L1.5 5 L7 8.5' fill='none' stroke='%232a211b' stroke-width='1.2'/%3E%3C/svg%3E") left center / 8px 10px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='10'%3E%3Cpath d='M1 1.5 L6.5 5 L1 8.5' fill='none' stroke='%232a211b' stroke-width='1.2'/%3E%3C/svg%3E") right center / 8px 10px no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / calc(100% - 4px) 1px no-repeat; }
#colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
#colors .sw, #colors label { position: relative; aspect-ratio: 1.45; border: 1.5px solid var(--ink); border-radius: 1px; padding: 0;
  background-image: url(img/grain.jpg); background-size: 90px; background-blend-mode: multiply; }
#colors .sw.sel, #colors label.sel { outline: 2px solid var(--ink); outline-offset: 2px; }
#colors label { cursor: pointer; display: grid; place-items: center; font-size: 18px; background-color: var(--card); overflow: hidden; }
#colors label input { position: absolute; inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); opacity: 0; cursor: pointer; border: 0; padding: 0; }
#shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
#shapes button { background: none; border: 1.4px solid transparent; border-radius: 1px; padding: 3px 1px; display: grid; place-items: center; }
#shapes button:hover { border-color: var(--pencil); }
#shapes button.sel { border-color: var(--ink); background: rgba(42, 33, 27, .05); }
#shapes canvas.ico { width: 100%; max-width: 64px; height: auto; display: block; }
#shapes img { width: 100%; max-width: 58px; height: auto; max-height: 44px; object-fit: contain; display: block; }
#name { width: 100%; font: 17px Drafting, cursive; letter-spacing: .12em; text-transform: uppercase; color: var(--ink);
  background: rgba(255, 252, 244, .45); border: 1.3px solid var(--ink); border-radius: 1px; padding: 6px 10px 4px; }
#name::placeholder { color: var(--pencil); }
#name:focus { outline: 1.5px dashed var(--pencil); outline-offset: 2px; }
#preview { width: 100%; height: 62px; display: block; }
#card > * { flex-shrink: 0; }
#leanText { font-size: 13.5px; line-height: 1.35; min-height: 2.7em; }
#leanText b { font-weight: 400; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
#bPlace, .fitB { margin-top: 2px; background: transparent; border: 1.5px solid var(--ink); border-radius: 1px;
  box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4.4px var(--ink); padding: 11px 8px 9px;
  font-family: Fell, Georgia, serif; font-size: 21px; letter-spacing: .05em; text-transform: uppercase; }
#bPlace:hover:not(:disabled), .fitB:hover:not(:disabled) { background: rgba(42, 33, 27, .07); }
#bPlace:disabled, .fitB:disabled { color: var(--pencil); cursor: default; }
#fitBox { display: flex; flex-direction: column; gap: 6px; }
#fitBox[hidden] { display: none; }
#fitBox h3 { color: var(--red); }
.fitRow { display: flex; flex-direction: column; gap: 3px; }
.fitB { width: 100%; font-size: 17px; padding: 9px 6px 7px; }
.fitRow[data-status="on"] .fitB:disabled { color: var(--ink); }
.fitRow[data-status="on"] .fitB:disabled::before { content: "\2713  "; }
.fitText { font-size: 12.5px; line-height: 1.32; color: #4a3f37; }
.fitText b { font-weight: 400; text-decoration: underline; text-underline-offset: 2px; }
#leanText .sup { color: #3f5f2e; }
#make { display: flex; flex-direction: column; gap: inherit; }
#make > * { flex-shrink: 0; }
#make[hidden], #barBox[hidden], #bFind[hidden], #barPips[hidden] { display: none; }
#barBox { display: flex; flex-direction: column; gap: 5px; }
#barBox h3 { color: var(--red); }
#barPips { display: flex; gap: 8px; justify-content: center; padding: 2px 0; }
#barPips i { width: 58px; height: 12px; border: 1.5px solid var(--ink); border-radius: 2px; background: transparent; }
#barPips i.on { background: linear-gradient(#6d655e, #34302c); box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
#barPips i.slack { background: repeating-linear-gradient(90deg, #8b6a4e 0 5px, #b48b62 5px 9px); opacity: .55; }
#barPips.glow i.on { box-shadow: 0 0 9px 2px rgba(236, 178, 64, .85); }
#barText { font-size: 13.5px; line-height: 1.35; }
#barText b { font-weight: 400; text-decoration: underline; text-underline-offset: 2px; }
#bPlace.bar:not(:disabled), .fitB.bar:not(:disabled) { color: var(--red); border-color: var(--red); box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4.4px var(--red); animation: barCall 2.4s ease-in-out infinite; }
@keyframes barCall { 50% { background: rgba(184, 64, 42, .09); } }
#bFind { background: none; border: 0; border-bottom: 1px dashed var(--ink); align-self: center; padding: 2px 4px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
#hint { font-size: 12px; line-height: 1.35; color: #5b5048; }

/* notes on the sheet */
#toast { position: fixed; left: 50%; top: 58px; transform: translate(-50%, -6px); max-width: min(92vw, 440px); z-index: 6;
  background: url(img/paper.jpg) 40px 0 / 512px repeat, var(--card); border: 1.2px solid var(--ink); box-shadow: 2px 3px 0 rgba(42, 33, 27, .14);
  padding: 8px 14px 6px; font-size: 15px; text-align: center; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#tip { position: fixed; z-index: 6; pointer-events: none; background: var(--card); border: 1.2px solid var(--ink); padding: 4px 9px 3px;
  font-size: 13px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; transform: translate(-50%, -135%); }
#sheet { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px; background: rgba(42, 33, 27, .32); }
#sheet[hidden] { display: none; }
.note { width: 100%; max-width: 450px; max-height: 90vh; overflow-y: auto; background: url(img/paper.jpg) 0 0 / 512px repeat, var(--card);
  border: 1.5px solid var(--ink); box-shadow: inset 0 0 0 4px var(--card), inset 0 0 0 5.3px var(--ink), 4px 6px 0 rgba(42, 33, 27, .2); padding: 20px 22px; }
.note h2 { margin: 0 0 6px; font-family: Fell, Georgia, serif; font-weight: 400; font-size: 26px; }
.note p, .note li { font-size: 15.5px; line-height: 1.45; }
.note ol { padding-left: 20px; margin: 6px 0; }
.note b { font-weight: 400; text-decoration: underline; text-underline-offset: 2px; }
.note .go { width: 100%; margin-top: 10px; background: transparent; border: 1.5px solid var(--ink);
  box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4.4px var(--ink); padding: 11px; font-family: Fell, Georgia, serif; font-size: 19px; text-transform: uppercase; }
.note .go.quiet { box-shadow: none; font-family: Drafting, cursive; font-size: 15px; }
.note table { width: 100%; border-collapse: collapse; font-size: 15px; }
.note td { padding: 5px 4px 3px; border-bottom: 1px solid rgba(42, 33, 27, .25); }
.note td:last-child { text-align: right; font-family: Fell, Georgia, serif; font-size: 18px; }
.note tr.mine td { color: var(--red); }
.note a { color: var(--ink); }
.note .muted { color: #6d6157; font-size: 13.5px; }

/* short landscape screens: a tighter card */
@media (max-height: 640px) and (min-aspect-ratio: 1/1) and (min-width: 720px) {
  #colors { grid-template-columns: repeat(8, 1fr); gap: 4px; }
  #shapes { grid-template-columns: repeat(8, 1fr); gap: 2px; }
  #shapes canvas.ico { max-height: 22px; width: auto; max-width: 100%; }
#shapes img { max-height: 22px; }
  #colors { grid-template-columns: repeat(8, minmax(0, 1fr)) !important; }
  #colors .sw, #colors label { height: 16px; aspect-ratio: auto; min-width: 0; }
  #card h2 { display: none; }
  .tabs button { font-size: 11px; white-space: nowrap; }
  #leanText { font-size: 11.5px; line-height: 1.25; }
  #prevBox, #hint, #card .arrowRule { display: none; }
  #card { padding: 24px 10px 8px; gap: 4px; }
  #card h2 { font-size: 17px; }
  #card h3 { font-size: 12px; }
  #name { font-size: 15px; padding: 4px 8px 3px; }
  #bPlace { font-size: 17px; padding: 8px; }
  #leanText { font-size: 12px; min-height: 0; }
  .tbMotto, .tbDate, .tbSub { display: none; }
  .scBar { margin: 2px 0 1px; height: 3px; }
  .scItem { padding: 2px 10px; }
  .scTop b { font-size: 16px; }
  .scC { font-size: 11.5px; }
  .scale { margin: 0 -10px; }
  #fitBox { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  #fitBox h3 { grid-column: 1 / -1; }
  .fitText { display: none; }
  .fitB { font-size: 12px; padding: 6px 2px 5px; }
  #tb { width: 180px; padding: 7px 10px 6px; }
  .tbTitle { font-size: 19px; }
  .tbGrid b { font-size: 22px; }
}

/* phones held upright and other narrow screens: the card sits at the foot */
@media (max-width: 719px), (max-aspect-ratio: 1/1) {
  #cardWrap { left: 50%; top: auto; bottom: 6px; transform: translateX(-50%); width: min(540px, calc(100% - 12px)); }
  #clip { width: 50px; }
  #card { margin-top: 16px; max-height: 46vh; padding: 20px 10px 8px; gap: 4px; }
  #card h2 { display: none; }
  #card h3 { font-size: 11.5px; }
  #card .arrowRule, #prevBox, #hint { display: none; }
  #colors { grid-template-columns: repeat(8, 1fr); gap: 4px; }
  #colors .sw, #colors label { aspect-ratio: 1.35; }
  #shapes { grid-template-columns: repeat(8, 1fr); gap: 2px; }
  #name { font-size: 15px; padding: 5px 8px 3px; }
  #leanText { font-size: 12.5px; min-height: 0; }
  #bPlace { font-size: 18px; padding: 9px; }
  #fitBox { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  #fitBox h3 { grid-column: 1 / -1; }
  .fitText { display: none; }
  .fitB { font-size: 12.5px; padding: 7px 2px 5px; line-height: 1.1; }
  #tools { left: 8px; right: auto; top: 8px; gap: 4px; }
  #tools button { font-size: 11px; padding: 4px 7px 3px; letter-spacing: .06em; }
  #tb { top: 8px; right: 8px; bottom: auto; width: 150px; padding: 6px 8px 5px; box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px var(--ink); }
  .tbTitle { font-size: 15px; }
  .tbSub, .tbMotto, .tbDate { display: none; }
  .scN { font-size: 9px; }
  .scale { margin: 0 -8px; }
  .scItem { padding: 3px 8px 2px; }
  .scTop { font-size: 9.5px; }
  .scTop b { font-size: 14px; }
  .scC { font-size: 10px; line-height: 1.15; }
  .scBar { height: 3px; margin: 2px 0 1px; }
  .tbGrid { margin: 5px -8px 0; }
  .tbGrid > div { padding: 3px 2px; font-size: 9.5px; }
  .tbGrid b { font-size: 19px; }
  .tbRow { margin: 0 -8px; padding: 3px 8px 2px; font-size: 9.5px; border-bottom: 0; }
  #stamp { font-size: 12px; padding: 2px 6px; border-width: 2px; }
  #stamp small { font-size: 9px; }
  #toast { top: 38vh; }
}
@media (max-width: 400px) and (max-aspect-ratio: 1/1) {
  #tools #bHelp { font-size: 0; padding: 4px 9px 3px; }
  #tools #bHelp::after { content: "?"; font-size: 13px; }
}

/* the swatches are washes of pigment too */
#colors .sw { background-image: url(img/wash.jpg); background-size: 90px; background-blend-mode: multiply; }
#colors .sw:nth-child(3n) { background-position: 30px 40px; } #colors .sw:nth-child(3n+1) { background-position: 70px 10px; }
#stamp { filter: url(#stampRough); }
