/* Canton Cube: the points map's bar, stage and drawer, with a cube on stage. */
:root {
  --u: #f4f4f2;
  --d: #ffd500;
  --f: #009b48;
  --b: #0046ad;
  --l: #ff5800;
  --r: #b71234;
  --gap: #050607;
  --ok: #2fbf71;
  /* one sticker: fits the stage, which is narrower while the drawer is docked */
  --s: clamp(30px, min(10vw, 8vh), 64px);
}
@media (min-width: 821px) { :root { --s: clamp(40px, min(calc((100vw - 380px) / 11), 8.5vh), 76px); } }

[hidden] { display: none !important; }
.muted { color: var(--muted); }

a.brand { color: var(--text); text-decoration: none; }
#giveBtn { margin-left: auto; white-space: nowrap; }
#giveBtn.done { background: var(--ok); }
#bar { background: linear-gradient(90deg, var(--l), var(--d), var(--f), var(--b)); }
#sStatus.late { color: var(--coop); }
#sStatus.ok { color: var(--ok); }

/* ---- the cube ------------------------------------------------------------ */

.scene { position: absolute; inset: 0; display: grid; place-items: center; perspective: 1100px; touch-action: none; cursor: grab; user-select: none; }
.scene.dragging { cursor: grabbing; }
.cube { position: relative; width: calc(var(--s) * 3); height: calc(var(--s) * 3); transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(.2, .8, .2, 1); }
.scene.dragging .cube { transition: none; }
.cube .face { position: absolute; inset: 0; }
.cube .face[data-face="F"] { transform: translateZ(calc(var(--s) * 1.5)); }
.cube .face[data-face="B"] { transform: rotateY(180deg) translateZ(calc(var(--s) * 1.5)); }
.cube .face[data-face="R"] { transform: rotateY(90deg) translateZ(calc(var(--s) * 1.5)); }
.cube .face[data-face="L"] { transform: rotateY(-90deg) translateZ(calc(var(--s) * 1.5)); }
.cube .face[data-face="U"] { transform: rotateX(90deg) translateZ(calc(var(--s) * 1.5)); }
.cube .face[data-face="D"] { transform: rotateX(-90deg) translateZ(calc(var(--s) * 1.5)); }

.face {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: calc(var(--s) * 0.06); padding: calc(var(--s) * 0.06);
  background: var(--gap); border-radius: calc(var(--s) * 0.16); backface-visibility: hidden;
}

/* A sticker still to give is a dark tile with the colour as a rim; a given
   one is the full colour. */
.st {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 0; cursor: pointer;
  border: 0; border-radius: calc(var(--s) * 0.1);
  background: color-mix(in srgb, var(--c) 16%, #15171b); color: color-mix(in srgb, var(--c) 75%, #fff);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 45%, transparent);
  font: 700 calc(var(--s) * 0.24)/1 system-ui, sans-serif; letter-spacing: 0.02em;
  transition: background 0.3s, color 0.3s, box-shadow 0.2s, filter 0.2s;
}
.st.given { background: var(--c); color: rgba(0, 0, 0, 0.62); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.st.given.light-text { color: rgba(255, 255, 255, 0.85); }
.st.due:not(.given) { animation: due 1.6s ease-in-out infinite; }
.st.hot { filter: brightness(1.35); box-shadow: inset 0 0 0 3px var(--text); }
.st.sel { box-shadow: inset 0 0 0 3px var(--accent), 0 0 18px var(--accent); }
.st.pop { animation: pop 0.5s ease-out; }
.st span { pointer-events: none; }
@keyframes due { 50% { box-shadow: inset 0 0 0 3px var(--c), 0 0 14px color-mix(in srgb, var(--c) 70%, transparent); } }
@keyframes pop { 40% { transform: scale(1.25); filter: brightness(1.6); } }

.net {
  position: absolute; inset: 0; display: grid; gap: 6px; place-content: center;
  --s: clamp(22px, min(6.4vw, 7vh), 62px);
  grid-template-columns: repeat(4, calc(var(--s) * 3));
  grid-template-areas: ". U . ." "L F R B" ". D . .";
}
@media (min-width: 821px) { .net { --s: clamp(26px, min(calc((100vw - 380px) / 14), 8vh), 66px); } }

.ctl button[aria-pressed="true"] { color: var(--accent); }
/* the detail card sits on the left: move the cube out from under it */
@media (min-width: 821px) {
  body.picked .scene, body.picked .net { left: 392px; }
  body.picked .net { --s: clamp(18px, min(calc((100vw - 772px) / 13), 8vh), 66px); }
}

/* ---- detail card ---------------------------------------------------------- */

#detail .kind { background: var(--field); }
#detail .value .ok { color: var(--ok); }
.shares { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.shares li { display: grid; grid-template-columns: 14px 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--field); }
.shares li b { font-size: 13px; }
.shares li .amt { font-weight: 650; }
.shares li small { grid-column: 2 / 4; color: var(--muted); font-size: 12px; }
.shares li small a { color: var(--accent); }
.shares select { grid-column: 2 / 4; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-size: 12px; }
.chip { width: 14px; height: 14px; border-radius: 4px; background: var(--c); flex: none; }
.more { margin-top: 12px; font-size: 13px; }
.more summary { cursor: pointer; color: var(--muted); }
.more label { display: grid; gap: 4px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.more input, .more select { height: 32px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: var(--field); color: var(--text); font: inherit; outline: none; }
.more input:focus { border-color: var(--accent); }
#detail .actions .primary { flex: 1; height: 38px; font-size: 15px; }

/* ---- drawer panes -------------------------------------------------------- */

.pane p { margin: 0 0 10px; }
.pane .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pane a { color: var(--accent); }
.ghost.file { display: inline-flex; align-items: center; cursor: pointer; font-size: 14px; }
.ghost.file input { display: none; }

.summary { padding: 14px; margin-bottom: 8px; border-radius: 10px; background: var(--field); }
.summary b { font-size: 22px; }
.summary small { display: block; color: var(--muted); font-size: 12px; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 26px 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 8px; border-bottom: 1px solid var(--line); border-radius: 8px; }
.steps li.now { background: var(--field); box-shadow: inset 3px 0 0 var(--accent); }
.steps .n { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--field); font-size: 12px; font-weight: 700; color: var(--muted); }
.steps li.done .n { background: var(--ok); color: #fff; }
.steps li.late .n { background: var(--coop); color: #fff; }
.steps .when { font-weight: 600; display: block; }
.steps .amt { color: var(--muted); font-size: 12px; text-align: right; }
.steps .pieces { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 6px; }
.steps .pieces button {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 4px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--text); font-size: 13px;
}
.steps .pieces button:hover { background: var(--field); }
.steps .pieces button.given { border-color: transparent; background: var(--field); color: var(--muted); text-decoration: line-through; }
.chips { display: inline-flex; gap: 2px; }
.chips .chip { width: 9px; height: 9px; border-radius: 3px; }

.cause { display: grid; grid-template-columns: 14px 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cause b { font-weight: 600; }
.cause span { color: var(--muted); font-size: 13px; }
.cause .track { grid-column: 2 / 4; width: 100%; }
.cause .track span { background: var(--c); }
.cause.solved b::after { content: " ✓"; color: var(--ok); }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.badge-card { display: grid; gap: 4px; justify-items: start; padding: 12px; border-radius: 12px; background: var(--field); opacity: 0.5; }
.badge-card.won { opacity: 1; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), var(--field)); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.badge-card .ico { font-size: 22px; line-height: 1; filter: grayscale(1); }
.badge-card.won .ico { filter: none; }
.badge-card b { font-size: 13px; }
.badge-card small { color: var(--muted); font-size: 12px; }

/* ---- setup form, first-run sheet ---------------------------------------- */

.setup { display: grid; gap: 12px; }
.setup label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.setup input[type="text"], .setup select {
  height: 40px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px;
  background: var(--field); color: var(--text); font: inherit; font-size: 16px; outline: none;
}
.setup input:focus, .setup select:focus { border-color: var(--accent); }
.setup .check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.setup .check input { width: 16px; height: 16px; accent-color: var(--accent); }
.setup .quick { display: flex; gap: 6px; }
.setup .quick button { flex: 1; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--text); cursor: pointer; font-weight: 600; }
.setup .quick button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.setup .preview { padding: 12px 14px; border-radius: 10px; background: var(--field); font-size: 14px; }
.setup .preview b { font-size: 20px; display: block; }
.setup .preview small { color: var(--muted); }
.setup button.primary { height: 42px; font-size: 15px; }
.setup .fine { margin: 0; font-size: 12px; color: var(--muted); }

#sheetBackdrop { position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, 0.55); }
.sheet {
  position: fixed; z-index: 30; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto;
  padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow);
}
.sheet h2 { margin: 0; font-size: 22px; }
.sheet .intro { margin: 0; color: var(--muted); }

/* ---- win -------------------------------------------------------------- */

#win { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); padding: 16px; }
.win-card { max-width: 380px; padding: 28px 24px; border-radius: 20px; background: var(--panel); text-align: center; box-shadow: var(--shadow); animation: rise 0.5s cubic-bezier(.2, .8, .2, 1); }
.win-card h2 { margin: 14px 0 8px; font-size: 26px; }
.win-card p { color: var(--muted); margin: 0 0 18px; }
.win-cube { width: 72px; height: 72px; margin: 0 auto; border-radius: 14px; background: conic-gradient(var(--u), var(--d), var(--f), var(--b), var(--l), var(--r), var(--u)); animation: spin 4s linear infinite; }
@keyframes rise { from { transform: translateY(30px) scale(0.9); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.confetti { position: fixed; z-index: 50; width: 8px; height: 12px; border-radius: 2px; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .cube { transition: none; }
  .st.due:not(.given), .st.pop, .win-cube { animation: none; }
}

@media (max-width: 820px) {
  .stat:not(.total) { display: none; }
  #detail { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 60%; }
}

/* phones: the detail card is a bottom sheet, so the cube moves up above it
   and messages show at the top */
@media (max-width: 820px) {
  body.picked .scene, body.picked .net { bottom: 60%; }
  body.picked .net { --s: clamp(16px, min(6vw, 4.5vh), 40px); }
  body.picked #toast { top: 64px; bottom: auto; }
}

/* ---- account ------------------------------------------------------------- */

#acct .primary { width: 100%; height: 36px; margin-bottom: 6px; }
#acct input.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.04em; text-transform: uppercase; }
a.ghost.link { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
a.ghost.link:hover { background: var(--field); }
.sheet .ghost { height: 36px; }
.shares li small.need { margin-top: 2px; line-height: 1.45; }
.shares li .links { display: block; margin-top: 2px; }
.shares li details.need { grid-column: 2 / 4; font-size: 12px; color: var(--muted); }
.shares li details.need summary { cursor: pointer; color: var(--text); font-weight: 600; }
.shares li details.need ul { margin: 4px 0 0; padding-left: 16px; line-height: 1.45; }
.shares li details.need li { display: list-item; padding: 0 0 4px; background: none; border-radius: 0; }
.shares li details.need b { font-weight: 650; color: var(--text); }
.shares li details.need a, .cause small a, .note-s a { color: var(--accent); }
.cause small { grid-column: 2 / 4; color: var(--muted); font-size: 12px; }

/* Cuts table in the Causes tab */
.cuts { width: 100%; border-collapse: collapse; font-size: 13px; margin: 4px 0 8px; }
.cuts th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.cuts td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cuts td:first-child { white-space: nowrap; }
.cuts td:first-child .chip { display: inline-block; vertical-align: -1px; margin-right: 8px; }
.cuts th:last-child, .cuts td:last-child { text-align: right; white-space: nowrap; }
.cuts td a { color: var(--accent); }
.cuts tfoot td { font-weight: 650; border-bottom: 0; }
