/* The table's structure: the stage, the deal, the slots, and the small pieces. */
:root {
  --card-scale: 1;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-title: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --ink: #e3e3e1;
  --muted: #a5a6a7;
  --stock: #222426;
  --page: #0c0e10;
  --card-line: #8a8c8e35;
  --card-shadow:
    0 1px 0 #45484a, 0 2px 0 #383b3d, 0 3px 0 #2d3032, 0 4px 0 #1b1d1f,
    0 6px 5px -3px #0009, 0 16px 23px -12px #000b;
  --card-hover-shadow:
    0 1px 0 #45484a, 0 2px 0 #383b3d, 0 3px 0 #2d3032, 0 4px 0 #1b1d1f,
    0 10px 10px -5px #0009, 0 22px 28px -12px #000b;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Cpath fill='%23808080' filter='url(%23n)' opacity='.12' d='M0 0h180v180H0z'/%3E%3C/svg%3E");
  --table-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Cpath fill='%23808080' filter='url(%23n)' opacity='.035' d='M0 0h180v180H0z'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  min-height: 100vh;
  color: #d5dad7;
  background-color: var(--page);
  background-image: var(--table-grain);
  font: 14px/1.6 var(--font-sans);
  overflow-x: clip;
}
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, .card-wrapper:focus-visible {
  outline: 2px solid #c6cbce;
  outline-offset: 5px;
}

.stage-container { max-width: 1460px; margin: auto; padding: 40px 46px 96px; }

/* The deal is a flow, not a grid: every card carries its own physical shape. */
.cards-grid {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  align-content: flex-start;
  justify-content: center;
  gap: 54px 38px;
}
.card-table-scene { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 10; }

.card-slot {
  width: min(calc(var(--face-w, 300) * 1px * var(--card-scale)), calc(100vw - 56px));
  aspect-ratio: var(--face-aspect, 0.75);
  pointer-events: none;
}

/* A section starts its own row, whether it is printed or dealt as a card. */
.deck-break { flex: 1 0 100%; height: 0; }
/* Two row gaps separate a heading and its prints; pull that pair 30% closer. */
.card-slot[data-kind='heading'] + .deck-break { margin-bottom: -32px; }

/* A break in the deal, printed straight onto the table. */
.deck-heading { flex: 1 0 100%; padding: 26px 4px 2px; }
.deck-heading:first-of-type { padding-top: 4px; }
.deck-heading-title {
  color: #cfd3d5;
  font: 500 clamp(19px, 2.4vw, 27px)/1.15 var(--font-title);
  letter-spacing: .12em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #000, 0 -1px 0 #ffffff0d;
}
.deck-heading-note {
  max-width: 62ch;
  margin-top: 9px;
  color: #8b9296;
  font-size: 12.5px;
  letter-spacing: .02em;
}

/* Equal-height tabletop pieces form one compact header. */
.table-header {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 22px;
  min-height: 32px;
  margin-bottom: 8px;
  pointer-events: none;
}
.table-identity, .table-controls { display: contents; }
.title-card-slot, .card-wrapper.title-card { width: 186px; height: 42px; flex-shrink: 0; }
.card-wrapper.title-card { position: absolute; top: 0; left: 0; aspect-ratio: auto; }
.card-filters {
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: auto;
}
.table-utilities { display: flex; align-items: center; gap: 10px; pointer-events: auto; }

.table-token, .size-token {
  height: 32px;
  color: #cacbcc;
  background: var(--grain), #2b2e30;
  border: 1px solid #65676945;
  border-radius: 3px;
  box-shadow: 0 1px 0 #45484a, 0 2px 0 #272a2c, 0 3px 3px -1px #000a;
  user-select: none;
  -webkit-user-select: none;
}
.table-token {
  --angle: -.2deg;
  --offset: 0px;

  padding: 0 10px;
  font: 500 9.5px/1.2 var(--font-sans);
  letter-spacing: .045em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateY(var(--offset)) rotate(var(--angle));
  transition: transform .13s ease, box-shadow .13s ease;
}
.table-token:nth-child(2) { --angle: .3deg; --offset: 1px; }
.table-token:nth-child(3) { --angle: -.15deg; }
.table-token:nth-child(4) { --angle: .2deg; }
.table-token:nth-child(5) { --angle: -.3deg; --offset: 1px; }
.card-filters .table-token[aria-pressed='true'],
.card-filters .table-token:active {
  transform: translateY(calc(var(--offset) - 3px)) rotate(calc(var(--angle) - .65deg));
  color: #eceeef;
}

.size-token {
  display: flex;
  align-items: center;
  width: 145px;
  padding: 0 15px;
  transform: rotate(-.2deg);
}
.size-token input {
  appearance: none;
  width: 100%;
  height: 4px;
  background: #111315;
  box-shadow: inset 0 1px 2px #0008, 0 1px 0 #ffffff15;
  cursor: ew-resize;
}
.size-token input::-webkit-slider-thumb {
  appearance: none;
  width: 10px;
  height: 16px;
  border-radius: 1px;
  background: var(--grain), #444b4f;
  border: 1px solid #626a6e55;
  box-shadow: 0 1px 0 #343b3f, 0 2px 2px #0005;
}
.size-token input::-moz-range-thumb {
  width: 10px;
  height: 16px;
  border-radius: 1px;
  background: var(--grain), #444b4f;
  border: 1px solid #626a6e55;
  box-shadow: 0 1px 0 #343b3f, 0 2px 2px #0005;
}
.sound-token { display: flex; align-items: center; justify-content: center; width: 34px; padding: 6px; }
.sound-token svg {
  width: 20px; height: 20px; display: block;
  stroke: currentColor; fill: none; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.sound-token[aria-pressed='false'] .sound-waves { display: none; }
.sound-token[aria-pressed='true'] .sound-muted { display: none; }

/* The header is a deal of small pieces, sharing the card simulation. */
.control-slot { visibility: hidden; pointer-events: none; }
.control-slot[hidden] { display: none; }
.mode-token svg {
  width: 19px; height: 19px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round;
}
.mode-token { display: flex; align-items: center; justify-content: center; width: 34px; padding: 6px; }
.mode-token[aria-pressed='false'] .mode-single { display: none; }
.mode-token[aria-pressed='true'] .mode-deal { display: none; }
.control-card { position: absolute; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.control-card > .table-token, .control-card > .size-token {
  width: 100%; margin: 0; transform: none; cursor: grab; touch-action: none;
}
.control-card .table-token[aria-pressed='true'] { transform: translateY(-2px) rotate(-.4deg); }
.control-card.is-dragging, .control-card.is-dragging > * { cursor: grabbing; outline: none; }
.control-card.is-offstage { visibility: hidden; pointer-events: none; }

/* Cards */
.card-wrapper {
  position: relative;
  width: min(calc(var(--face-w, 300) * 1px * var(--card-scale)), calc(100vw - 56px));
  aspect-ratio: var(--face-aspect, 0.75);
  perspective: 1400px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 5px;
}
.card-wrapper.kind-link, .card-wrapper.kind-note { cursor: pointer; }

/* A set of cards that belong side by side stays on one line, shrinking to fit. */
.card-row {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: center;
  gap: 0 20px;
}
.card-row .card-slot {
  width: min(
    calc(var(--face-w, 300) * 1px * var(--card-scale)),
    calc((100% - (var(--row-count, 1) - 1) * 20px) / var(--row-count, 1))
  );
}

@media (max-width: 900px) {
  /* Too narrow for one line: the days stack at the top rather than shrink away. */
  .card-row { flex-wrap: wrap; gap: 24px 18px; }
  .card-row .card-slot {
    width: min(calc(var(--face-w, 300) * 1px * var(--card-scale)), calc(50% - 12px));
  }
}

/* A print shown on its own takes the room it is given, within the viewport. */
.card-slot[data-kind='slideshow'],
.card-wrapper.kind-slideshow {
  width: min(
    calc(var(--face-w, 646) * 1px * var(--card-scale) * 2.6),
    calc(100vw - 90px),
    calc((100vh - 340px) * var(--face-aspect, 1.42))
  );
}

@supports (height: 100svh) {
  .card-slot[data-kind='slideshow'],
  .card-wrapper.kind-slideshow {
    width: min(
      calc(var(--face-w, 646) * 1px * var(--card-scale) * 2.6),
      calc(100vw - 90px),
      calc((100svh - 340px) * var(--face-aspect, 1.42))
    );
  }
}

.card-wrapper.is-hovered { z-index: 2; }
.card-wrapper.is-dragging { cursor: grabbing; z-index: 3; outline: none; }
.card-wrapper .tc-art-frame, .card-wrapper .tc-information { pointer-events: auto; touch-action: none; }

.playing-card {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 4%;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background-color: var(--stock);
  background-image: var(--grain);
  border: 1px solid #65676945;
  border-radius: 5px;
  box-shadow: var(--card-shadow);
  pointer-events: none;
  isolation: isolate;
  transition: box-shadow .2s ease;
}
.playing-card, .playing-card * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.card-wrapper.is-hovered .playing-card,
.card-wrapper:focus-visible .playing-card { box-shadow: var(--card-hover-shadow); }
.card-wrapper.is-dragging .playing-card { box-shadow: var(--card-shadow); }

.site-footer { max-width: 1360px; margin: auto; padding: 18px 46px 38px; }
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #777c80;
  font-size: 10px;
  letter-spacing: .055em;
  text-transform: uppercase;
  text-shadow: 0 -1px 0 #000, 0 1px 0 #ffffff0c;
  transform: rotate(-.15deg);
}
.footer-inner p { white-space: nowrap; }
.footer-links a { color: #777c80; text-decoration: none; }
.footer-links a:hover { color: #b3b7ba; }

@media (max-width: 1100px) { .card-filters { flex: 1; } }

@media (max-width: 760px) {
  .stage-container { padding: 32px 24px 64px; }
  .cards-grid { gap: 40px 26px; }
  .card-slot[data-kind='heading'] + .deck-break { margin-bottom: -24px; }
  .table-header { gap: 16px 12px; }
  .title-card-slot, .card-wrapper.title-card { width: 158px; }
  .card-filters { order: 3; flex: 1 0 100%; justify-content: flex-start; gap: 8px; }
  .size-token { width: 100px; padding: 0 12px; }
  .site-footer { padding: 18px 20px 26px; }
  .footer-inner, .footer-links a { font-size: 8px; letter-spacing: .045em; }
}

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