/* Le Carré: the card game, on the Encre sobre tokens of site.css. Flat surfaces,
   typographic cards, no text under 13 px, 44 px targets. Ownership reads in colour (cyan for
   the player, gold for the opponent, stone for the borne) and without it, in the corner
   notch: filled for the player, hollow for the opponent. */

body.cartes {
  --mine: var(--cyan);
  --theirs: var(--gold);
  --stone: #8b91a3;
  --mine-face: #143130;
  --theirs-face: #312816;
  --stone-face: #252a36;
  /* A board of three cells and two 8 px gaps inside the gutters, at most 108 px a cell. */
  --cell: min(108px, calc((100vw - 2 * var(--gutter) - 16px) / 3));
  --hand: min(64px, calc((100vw - 2 * var(--gutter) - 32px) / 5));
  --small: min(56px, calc((100vw - 2 * var(--gutter) - 32px) / 5));
}
@media (min-width: 960px) {
  body.cartes {
    --cell: 132px;
    --hand: 76px;
    --small: 76px;
  }
}
/* A phone held sideways (844 × 390): the board's size follows the height, both hands stand
   beside it in two columns, and title, board, hands and status fit the screen together. */
@media (orientation: landscape) and (max-height: 540px) {
  body.cartes {
    --cell: clamp(64px, calc((100dvh - 150px) / 3), 108px);
    --hand: clamp(44px, calc((100dvh - 166px) / 3), 64px);
    --small: var(--hand);
  }
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.muted {
  color: var(--text-3);
}

/* Page chrome. The bar wraps under the brand rather than scroll sideways on the narrowest
   phones. */
.cartes .bar-in {
  flex-wrap: wrap;
  height: auto;
  min-height: var(--bar);
}
.topline {
  display: flex;
  align-items: center;
  margin-top: var(--space-2);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--target);
  color: var(--text-2);
  text-decoration: none;
  font-size: var(--fs-15);
  font-weight: 600;
}
.back-link:hover {
  color: var(--text);
}
.storage-note {
  margin: var(--space-2) 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--gold);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-14);
}
.test-tools {
  margin: var(--space-10) 0 0;
  padding: var(--space-2) var(--space-4);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  font-size: var(--fs-14);
  color: var(--text-3);
}
.test-tools strong {
  color: var(--text-2);
  font-weight: 600;
}

/* Screens. */
.screen h1 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--fs-36);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.screen h2 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--fs-24);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.screen h3 {
  margin: var(--space-6) 0 var(--space-3);
  font-size: var(--fs-17);
}
/* Headings take the focus when a screen opens. After a keyboard action the ring shows where
   reading resumes; after a click, nothing. */
#view h1:focus,
#view h2:focus {
  outline: none;
}
#view h1:focus-visible,
#view h2:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
  border-radius: var(--r-sm);
}
.lead {
  max-width: 62ch;
  margin: 0 0 var(--space-4);
  color: var(--text-2);
  font-size: var(--fs-16);
}
.welcome {
  max-width: 62ch;
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--mine);
  background: var(--surface);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}
.btn-quiet {
  background: transparent;
  border-color: var(--line-2);
  color: var(--text);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}
.screen a {
  color: var(--cyan);
  text-underline-offset: 3px;
}

/* Home. */
.tiles {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-6) 0;
}
@media (min-width: 720px) {
  .tiles {
    grid-template-columns: repeat(3, 1fr);
  }
}
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: 88px;
  padding: var(--space-4);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.tile:hover {
  border-color: var(--line-2);
  filter: none;
}
.tile-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-18);
  font-weight: 700;
}
.tile-detail {
  color: var(--text-2);
  font-size: var(--fs-14);
}
.earn {
  max-width: 62ch;
}
.earn h2 {
  font-size: var(--fs-18);
}
.rules {
  max-width: 70ch;
  margin: var(--space-6) 0;
  color: var(--text-2);
}
.rules summary {
  min-height: var(--target);
  padding: 10px 0;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}
.rules li {
  margin: var(--space-2) 0;
}

/* Cards. */
.card {
  --size: var(--cell);
  --v: 18px;
  --face: var(--surface);
  --edge: var(--line-2);
  --fam: transparent;
  position: relative;
  display: block;
  width: var(--size);
  height: var(--size);
  flex: none;
  border: 2px solid var(--edge);
  border-radius: var(--r-md);
  background: var(--face);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 3px;
  border-radius: 0 0 2px 2px;
  background: var(--fam);
}
.size-board {
  --size: var(--cell);
  --v: 18px;
}
.size-hand {
  --size: var(--hand);
  --v: 14px;
}
.size-small {
  --size: var(--small);
  --v: 13px;
}
.size-album {
  --size: 104px;
  --v: 16px;
}
@media (min-width: 960px) {
  .size-board {
    --v: 20px;
  }
  .size-hand,
  .size-small {
    --v: 16px;
  }
}
.tone-mine {
  --face: var(--mine-face);
  --edge: var(--mine);
}
.tone-theirs {
  --face: var(--theirs-face);
  --edge: var(--theirs);
}
.tone-neutral {
  --face: var(--stone-face);
  --edge: var(--stone);
}
.fam-borne {
  --fam: var(--stone);
}
/* « Main cachée »: a card the opponent still holds, its back only. */
.card-back {
  --face: var(--theirs-face);
  --edge: var(--theirs);
}
.card-back::after {
  content: '';
  position: absolute;
  inset: 22%;
  border: 2px solid var(--theirs);
  border-radius: var(--r-sm);
  transform: rotate(45deg);
  opacity: 0.6;
}
.v {
  position: absolute;
  min-width: calc(var(--v) * 1.35);
  height: calc(var(--v) * 1.3);
  padding: 0 2px;
  border-radius: var(--r-sm);
  background: var(--bg);
  font-size: var(--v);
  font-weight: 700;
  line-height: calc(var(--v) * 1.3);
  text-align: center;
}
.v-n {
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
}
.v-s {
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
}
.v-w {
  left: 5%;
  top: 50%;
  transform: translateY(-50%);
}
.v-e {
  right: 5%;
  top: 50%;
  transform: translateY(-50%);
}
.v.windward {
  outline: 1px solid var(--text-2);
}
.v.lit {
  background: var(--edge);
  color: var(--bg);
}
.emblem {
  position: absolute;
  left: 34%;
  top: 34%;
  width: 32%;
  height: 32%;
  fill: none;
  stroke: var(--fam);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* The illustration's place, once a card has one: the square inside the four plates. */
.art {
  position: absolute;
  inset: 18%;
  width: 64%;
  height: 64%;
  object-fit: cover;
  border-radius: var(--r-sm);
}
.size-hand .emblem,
.size-small .emblem {
  left: 39%;
  top: 39%;
  width: 22%;
  height: 22%;
}
.notch {
  position: absolute;
  top: 6%;
  left: 6%;
  width: 12%;
  height: 12%;
  border-radius: 50%;
}
.tone-mine .notch {
  background: var(--mine);
}
.tone-theirs .notch {
  border: 2px solid var(--theirs);
}
.rarity {
  position: absolute;
  right: 6%;
  bottom: 4%;
  color: var(--text-3);
  font-size: var(--fs-13);
  line-height: 1;
}
.size-small .rarity,
.size-hand .rarity {
  display: none;
}
.wear {
  position: absolute;
  left: 6%;
  bottom: 4%;
  color: var(--text-2);
  font-size: var(--fs-13);
  line-height: 1;
  letter-spacing: -1px;
}

/* The match. */
.match-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-4);
  margin: var(--space-2) 0 var(--space-3);
}
.match-note,
.stake-line {
  margin: 0 0 var(--space-3);
  color: var(--gold);
  font-size: var(--fs-14);
  font-weight: 600;
}
.stake-closed {
  color: var(--gold);
  font-size: var(--fs-14);
}
.match-title {
  margin: 0;
  font-size: var(--fs-18);
}
.scoreline {
  margin: 0;
  font-size: var(--fs-16);
}
.scoreline b {
  font-size: var(--fs-22);
}
.who-mine,
.score-mine {
  color: var(--mine);
}
.who-theirs,
.score-theirs {
  color: var(--theirs);
}
.who {
  font-size: var(--fs-14);
  font-weight: 600;
}
.match-layout {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  grid-template-areas: 'theirs' 'board' 'mine';
}
.side-theirs {
  grid-area: theirs;
}
.board-wrap {
  grid-area: board;
}
.side-mine {
  grid-area: mine;
  display: flex;
  flex-direction: column;
  align-items: center;
}
@media (orientation: landscape) and (max-height: 540px) {
  .match-head {
    margin: 0 0 var(--space-2);
  }
  .match-layout {
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: 'mine board theirs';
    align-items: center;
    gap: var(--space-6);
  }
  .side-mine {
    justify-self: end;
  }
  .side-theirs {
    justify-self: start;
  }
  /* Two columns of hand cards; `.match` outranks the base `.hand` rule further down. */
  .match .hand {
    display: grid;
    grid-template-columns: repeat(2, var(--hand));
  }
  .match-status {
    min-height: 2.6em;
    margin-top: var(--space-2);
  }
}
@media (min-width: 960px) {
  .match-layout {
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: 'mine board theirs';
    align-items: center;
    gap: var(--space-8);
  }
  .side-mine {
    justify-self: end;
  }
  .side-theirs {
    justify-self: start;
  }
}
.board {
  display: grid;
  grid-template-columns: repeat(3, var(--cell));
  gap: 8px;
}
.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  perspective: 600px;
}
.cell.filled {
  border-color: transparent;
  background: transparent;
}
.cell:hover {
  filter: none;
}
.my-turn .cell:not(.filled):hover {
  border-color: var(--text-3);
}
.cell.legal {
  border: 2px dashed var(--mine);
}
.cell.armed {
  border: 2px solid var(--mine);
}
.cell .card {
  position: absolute;
  inset: 0;
}
.cell .ghost {
  opacity: 0.55;
  pointer-events: none;
}
.cell.threat .card {
  outline: 2px dashed var(--mine);
  outline-offset: 3px;
  animation: threat 900ms ease-in-out infinite;
}
@keyframes threat {
  50% {
    transform: scale(0.96);
  }
}
.duel {
  position: absolute;
  z-index: 2;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text-2);
  font-size: var(--fs-13);
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
}
.duel.wins {
  border-color: var(--mine);
  background: var(--mine);
  color: var(--on-cyan);
}
/* The label sits on the edge the two cards share, near a corner, so it never covers the
   value it names, centred on that edge. `duel-e`: the placed card's east side. */
.duel-e {
  left: 0;
  bottom: 4px;
  transform: translateX(-50%);
}
.duel-w {
  right: 0;
  top: 4px;
  transform: translateX(50%);
}
.duel-s {
  top: 0;
  right: 4px;
  transform: translateY(-50%);
}
.duel-n {
  bottom: 0;
  left: 4px;
  transform: translateY(50%);
}
.wind {
  margin: 0 0 var(--space-2);
  color: var(--text-2);
  font-size: var(--fs-13);
  text-align: center;
}
.wind span[aria-hidden] {
  margin-right: var(--space-1);
  font-weight: 700;
}
.wind .sr {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
  white-space: normal;
}
.hand {
  display: flex;
  gap: 8px;
  justify-content: center;
}
@media (min-width: 960px) {
  .hand {
    flex-direction: column;
  }
}
.slot {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  border-radius: var(--r-md);
  min-width: var(--target);
}
.hand-theirs .slot .card {
  transition: transform 200ms ease-out;
}
.hand-mine .slot .card {
  transition: transform 150ms ease-out;
}
.slot.played {
  width: var(--hand);
  height: var(--hand);
  border: 1px dashed var(--line);
}
.hand-theirs .slot.played {
  width: var(--small);
  height: var(--small);
}
button.slot:disabled {
  cursor: default;
}
.match:not(.my-turn) button.slot {
  cursor: default;
}
button.slot[aria-pressed='true'] .card {
  transform: translateY(-8px);
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
@media (min-width: 960px) {
  button.slot[aria-pressed='true'] .card {
    transform: translateX(8px);
  }
}
.slot.lift .card {
  transform: translateY(8px);
}
@media (min-width: 960px) {
  .slot.lift .card {
    transform: translateX(-8px);
  }
}
/* Drag and drop (card-drag.ts): only the cards that can be played take the touch away from
   scrolling. The copy under the pointer is placed through the CSSOM; the card it came from
   fades in the hand until the copy is played or back. */
.match.my-turn .hand-mine button.slot {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.drag-card {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  pointer-events: none;
  outline: 2px solid var(--mine);
  outline-offset: 2px;
}
.hand-mine[data-drag-slot='0'] [data-slot='0'] .card,
.hand-mine[data-drag-slot='1'] [data-slot='1'] .card,
.hand-mine[data-drag-slot='2'] [data-slot='2'] .card,
.hand-mine[data-drag-slot='3'] [data-slot='3'] .card,
.hand-mine[data-drag-slot='4'] [data-slot='4'] .card {
  opacity: 0.3;
}
.hand-caption {
  min-height: 1.5em;
  margin: var(--space-2) 0 0;
  color: var(--text-2);
  font-size: var(--fs-14);
}
.match-status {
  min-height: 3em;
  margin: var(--space-3) auto 0;
  max-width: 44ch;
  color: var(--text-2);
  font-size: var(--fs-15);
  text-align: center;
}
/* A finished game has emptied its status line and caption: they stop holding their place, so
   the result follows the hands. */
.match.over .match-status:empty,
.match.over .hand-caption:empty {
  display: none;
}
.match-end {
  max-width: 62ch;
  margin: 0 auto;
  text-align: center;
}
.match-end .actions {
  justify-content: center;
}
.result {
  margin: var(--space-3) 0;
  font-size: var(--fs-18);
  font-weight: 700;
}
.match-rules {
  margin: var(--space-4) 0 0;
  color: var(--text-3);
  font-size: var(--fs-13);
  text-align: center;
}

/* Setup forms. */
.setup {
  max-width: 760px;
}
.choice,
.picker {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.choice legend,
.picker legend {
  padding: 0 var(--space-2);
  font-weight: 700;
}
.choice-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: var(--target);
  padding: var(--space-2) 0;
  cursor: pointer;
}
.choice-option input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--lime);
}
.choice-option span {
  display: flex;
  flex-direction: column;
}
.choice-option small {
  color: var(--text-2);
  font-size: var(--fs-14);
}
.stake {
  border-color: var(--gold);
}
.picker-count {
  margin: 0 0 var(--space-3);
  color: var(--text-2);
  font-size: var(--fs-15);
}
.over-cap {
  color: var(--gold);
  font-weight: 700;
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
}
.pick {
  --hand: 48px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 64px;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
}
.pick[aria-pressed='true'] {
  border-color: var(--mine);
  background: var(--mine-face);
}
.pick:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}
.pick .size-hand {
  --v: 13px;
}
.pick-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pick-name {
  font-size: var(--fs-15);
  font-weight: 600;
  hyphens: auto;
}
.pick-total,
.pick-count {
  color: var(--text-2);
  font-size: var(--fs-13);
}

/* Album, boosters and hand previews. */
.album-family h3 {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
}
.album-family h3::before {
  content: '';
  width: 16px;
  height: 3px;
  align-self: center;
  border-radius: 2px;
  background: var(--fam);
}
.album-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, 104px);
  gap: var(--space-6) var(--space-2);
}
.album-card,
.offer-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  border: 0;
  background: none;
  border-radius: var(--r-md);
}
.album-name {
  max-width: 104px;
  font-size: var(--fs-14);
  font-weight: 600;
  text-align: center;
}
.album-card .card + .album-count {
  position: absolute;
  top: -8px;
  right: -8px;
}
.album-count {
  padding: 0 6px;
  border-radius: var(--r-sm);
  background: var(--raised);
  font-size: var(--fs-13);
  font-weight: 700;
}
/* The cards still to find: small places after the family's cards, five or more to a row. */
.album-missing-list {
  margin-top: var(--space-4);
}
.album-missing-list > p {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-14);
}
.album-missing-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.album-missing {
  display: grid;
  place-items: center;
  align-content: center;
  width: 60px;
  height: 48px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-size: var(--fs-13);
  line-height: 1.2;
}
/* The card's sheet, over the page where the player touched the card. */
.album-detail[open] {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  width: min(30rem, calc(100vw - 2 * var(--gutter)));
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
}
.album-detail::backdrop {
  background: rgb(0 0 0 / 0.6);
}
.album-detail .actions {
  margin-top: var(--space-3);
}
.album-detail h3 {
  margin: 0 0 var(--space-1);
}
.album-detail p {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-14);
}
.offer-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}
.offer-card[aria-pressed='true'] .card {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}
.offer-meta {
  max-width: 104px;
  color: var(--text-2);
  font-size: var(--fs-13);
  text-align: center;
}
.offer-note {
  min-height: 1.5em;
  color: var(--text-2);
}
.bag-rules {
  max-width: 62ch;
  margin-top: var(--space-6);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: var(--fs-14);
}
.preview-hand h3 {
  margin-bottom: var(--space-2);
}
.preview-cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}
.tries ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tries li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-2) 0;
}

/* Sharing. */
.share-preview {
  display: inline-block;
  margin: var(--space-3) 0 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font: inherit;
  font-size: var(--fs-16);
  line-height: 1.4;
  white-space: pre-wrap;
}
.share-field,
.link-field {
  display: block;
  width: 100%;
  max-width: 62ch;
  min-height: var(--target);
  margin: var(--space-2) 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-14);
}
.link-panel {
  max-width: 62ch;
  margin: var(--space-4) auto;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
}
.link-panel p {
  margin: 0 0 var(--space-2);
}
.link-panel .actions {
  margin: var(--space-3) 0 0;
}
.share-note {
  min-height: 1.5em;
  margin: var(--space-2) 0 0;
  color: var(--text-2);
  font-size: var(--fs-14);
}

/* The daily duel's take, under the result. */
.take .offer-row {
  justify-content: center;
}
