/* Mahjong on painted tiles. The table is WebGL; this file is the room around it. */
@font-face { font-family: Fraunces; src: url(fonts/Fraunces.woff2) format('woff2'); font-weight: 300 800; font-style: normal; font-display: swap; }
@font-face { font-family: Fraunces; src: url(fonts/Fraunces-Italic.woff2) format('woff2'); font-weight: 300 800; font-style: italic; font-display: swap; }

:root {
  --accent: #2f6f66;
  --room: #1c2326;
  --paper: #f3ecdc;
  --paper-dim: rgb(243 236 220 / 0.68);
  --glass: rgb(20 26 28 / 0.42);
  --line: rgb(243 236 220 / 0.2);
  font-family: Fraunces, Georgia, serif;
  font-variation-settings: 'SOFT' 100, 'opsz' 30;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--room); color: var(--paper); }
body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }

/* the room: one of the set's paintings, far out of focus */
#backdrop { position: fixed; inset: -8%; background: center / cover no-repeat; filter: blur(42px) saturate(0.85) brightness(0.62); transform: scale(1.1); transition: background-image 1.2s; }
#backdrop::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, transparent 30%, rgb(10 14 16 / 0.55) 100%); }

.app { position: relative; height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
#scene { width: 100%; height: 100%; min-height: 0; display: block; touch-action: none; }

.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: max(14px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 6px max(22px, env(safe-area-inset-left)); }
.name { display: flex; align-items: baseline; gap: 16px; min-width: 0; }
h1 { margin: 0; font-size: 1.7rem; font-weight: 420; font-style: italic; letter-spacing: 0.005em; font-variation-settings: 'SOFT' 100, 'opsz' 144; }
.link { color: var(--paper-dim); font-size: 0.95rem; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link:hover { color: var(--paper); }
.count { margin: 0; display: flex; gap: 22px; font-size: 0.95rem; color: var(--paper-dim); font-variant-numeric: tabular-nums; }
.count b { font-weight: 560; color: var(--paper); font-size: 1.15rem; margin-right: 3px; }
.switches { justify-self: end; display: flex; gap: 8px; }
.switches button, .tools button {
  padding: 9px 16px; border-radius: 999px; font-size: 0.95rem;
  background: var(--glass); box-shadow: inset 0 0 0 1px var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: background 0.2s, transform 0.1s;
}
.switches button b { font-weight: 600; }
.switches button[aria-pressed='false'] { color: var(--paper-dim); }
.switches button[aria-pressed='false'] b { font-weight: 400; }

.dock { display: grid; justify-items: center; gap: 10px; padding: 6px 16px max(16px, env(safe-area-inset-bottom)); }
#caption { margin: 0; min-height: 1.5em; font-size: 0.98rem; color: var(--paper-dim); text-align: center; max-width: 70ch; }
#caption a { color: var(--paper); text-decoration-color: var(--line); text-underline-offset: 4px; }
#caption span::before { content: '  '; white-space: pre; }
.tools { display: flex; gap: 8px; }
.tools button { padding: 11px 22px; font-size: 1rem; }
.tools button:active, .switches button:active { transform: scale(0.96); }
.tools button[disabled] { opacity: 0.4; cursor: default; }

dialog { width: min(520px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); border: 0; border-radius: 14px; padding: 26px; background: #f6f1e4; color: #1f2628; box-shadow: 0 40px 90px rgb(0 0 0 / 0.55); font-family: inherit; }
dialog::backdrop { background: rgb(12 16 18 / 0.5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog h2 { margin: 0 0 8px; font-size: 1.7rem; font-weight: 440; font-style: italic; line-height: 1.15; font-variation-settings: 'SOFT' 100, 'opsz' 144; }
dialog p { margin: 0 0 20px; font-size: 1.02rem; line-height: 1.55; }
dialog figure { margin: 0 0 18px; }
dialog figure img { display: block; width: 100%; max-height: 46dvh; object-fit: contain; background: #e7e0cf; border-radius: 6px; }
dialog figcaption { margin-top: 8px; font-size: 0.85rem; line-height: 1.4; color: #5a625f; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices button { flex: 1 1 auto; padding: 12px 18px; border-radius: 999px; font-size: 1rem; box-shadow: inset 0 0 0 1px rgb(31 38 40 / 0.3); }
.choices button.primary { background: var(--accent); color: #fff; box-shadow: none; }
#sets { display: grid; gap: 10px; margin-bottom: 18px; }
#sets button { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; text-align: left; padding: 8px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgb(31 38 40 / 0.18); }
#sets button[aria-pressed='true'] { box-shadow: inset 0 0 0 2px #1f2628; }
#sets img { grid-row: 1 / 3; width: 96px; height: 72px; object-fit: cover; border-radius: 6px; }
#sets strong { align-self: end; font-size: 1.12rem; font-weight: 560; }
#sets span { align-self: start; font-size: 0.9rem; line-height: 1.35; color: #5a625f; }
.nojs { position: fixed; inset: auto 0 40%; text-align: center; }

@media (hover: hover) {
  .switches button:hover, .tools button:hover:not([disabled]) { background: rgb(20 26 28 / 0.62); }
  .choices button:hover { filter: brightness(1.08); }
}
@media (max-width: 760px) {
  .bar { grid-template-columns: 1fr auto; row-gap: 4px; padding-left: 14px; padding-right: 14px; }
  .name { flex-direction: column; gap: 0; }
  h1 { font-size: 1.4rem; }
  .link { font-size: 0.85rem; max-width: 46vw; text-align: left; }
  .count { grid-column: 1 / -1; grid-row: 2; gap: 16px; font-size: 0.88rem; }
  .count b { font-size: 1rem; }
  .switches button { padding: 7px 11px; font-size: 0.85rem; }
  .tools { width: 100%; }
  .tools button { flex: 1; padding: 12px 4px; }
  #caption { font-size: 0.88rem; }
}
@media (prefers-reduced-motion: reduce) { #backdrop { transition: none; } }
