*, *::before, *::after { box-sizing: border-box; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  margin: 0;
  background: var(--snow);
  color: var(--chocolate);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, figure, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }

/* Short pages keep the footer at the bottom */
main { flex: 1 0 auto; width: 100%; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Type */
.title {
  font-size: 34px;
  font-weight: 600;
  line-height: 1.03;
  letter-spacing: -0.035em;
}
.title-quiet { color: var(--ink-quiet); }

.display {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: 0.86;
}

.lead {
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Buttons */
.btn-split,
.btn-outline {
  display: inline-flex;
  align-items: stretch;
  height: var(--control-height);
  padding: 0;
  border: 0;
  background: none;
  font: 500 15px/1 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn-split { color: var(--snow); }
.btn-split-label {
  display: flex;
  align-items: center;
  flex: 1;
  padding: 0 18px;
  background: var(--chocolate);
  transition: background var(--ease-normal);
}
.btn-split-arrow {
  display: grid;
  place-items: center;
  width: var(--control-height);
  flex-shrink: 0;
  background: var(--red);
  color: #fff;
}
.btn-split-arrow svg { transition: transform var(--ease-normal); }
.btn-split:hover .btn-split-label { background: #2F201F; }
.btn-split:hover .btn-split-arrow svg { transform: translateX(3px); }
.btn-split:disabled { opacity: 0.5; cursor: default; }

.btn-outline {
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1.5px var(--ink-line);
  color: var(--chocolate);
  transition: box-shadow var(--ease-normal);
}
.btn-outline:hover { box-shadow: inset 0 0 0 1.5px var(--chocolate); }

/* Swiss plate drawn in the plate font. Size it with width/height and font-size. */
.plate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  padding: 0 0.5em;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 0 1px #111;
  font-family: var(--font-plate);
  line-height: 1;
  color: #111;
  white-space: nowrap;
}
/* Shield: red with a white cross */
.plate i {
  position: relative;
  flex-shrink: 0;
  width: 0.62em;
  aspect-ratio: 8 / 9;
  background: var(--red);
  border-radius: 1px 1px 3px 3px;
}
.plate i::before,
.plate i::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 46%;
  background: #fff;
  transform: translate(-50%, -50%);
}
.plate i::before { width: 60%; height: 16%; }
.plate i::after  { width: 16%; height: 60%; }

/* Laid exactly over a blurred plate in a photo; position it with left/top/width/height in % */
.plate--on-photo {
  position: absolute;
  padding: 0;
  gap: 6%;
  font-size: var(--plate-size, 12px);
  /* Lit like the photo: warm white, a thin worn rule, a touch soft, no hard outline */
  background: linear-gradient(176deg, #F7F5F1 0%, #E6E2DC 100%);
  color: #1E1E1E;
  border-radius: 0.12em;
  box-shadow: inset 0 0 0 0.04em rgba(17,17,17,0.55);
  filter: blur(0.3px) brightness(0.92);
}
.plate--on-photo i { filter: saturate(0.85); }

/* Signature button: a white Swiss plate */
.btn-plate {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  height: 60px;
  padding: 0 22px 0 18px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #111, 0 10px 30px rgba(40,26,24,0.18);
  font-family: var(--font-plate);
  font-size: 24px;
  line-height: 1;
  color: #111;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--ease-normal), box-shadow var(--ease-normal);
}
.btn-plate i {
  position: relative;
  width: 18px;
  aspect-ratio: 8 / 9;
  background: var(--red);
  border-radius: 1px 1px 4px 4px;
}
.btn-plate i::before,
.btn-plate i::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 46%;
  background: #fff;
  transform: translate(-50%, -50%);
}
.btn-plate i::before { width: 60%; height: 16%; }
.btn-plate i::after  { width: 16%; height: 60%; }
.btn-plate:hover { transform: translateY(-2px); box-shadow: 0 0 0 2px #111, 0 16px 36px rgba(40,26,24,0.24); }

/*
 * Phone mockup. Every size inside is in px of a 136px wide phone, multiplied
 * by --p, so a phone of any size keeps its proportions.
 */
.phone {
  --p: 1px;
  position: relative;
  width: calc(136 * var(--p));
  aspect-ratio: 9 / 19.5;
  padding: calc(7 * var(--p));
  border-radius: calc(38 * var(--p));
  background: #111;
  transform: rotateY(24deg) rotateX(8deg) rotateZ(-9deg);
  box-shadow:
    0 0 0 calc(1.5 * var(--p)) #2a2a2a,
    calc(-2 * var(--p)) 0 0 calc(1.5 * var(--p)) #3a3a3a,
    calc(-24 * var(--p)) calc(34 * var(--p)) calc(60 * var(--p)) rgba(40,26,24,0.35);
  font-family: var(--font-body);
}
/* Mirror of the default tilt, for a phone that sits to the right of its text */
.phone--turn-left {
  transform: rotateY(-24deg) rotateX(8deg) rotateZ(9deg);
  box-shadow:
    0 0 0 calc(1.5 * var(--p)) #2a2a2a,
    calc(2 * var(--p)) 0 0 calc(1.5 * var(--p)) #3a3a3a,
    calc(24 * var(--p)) calc(34 * var(--p)) calc(60 * var(--p)) rgba(40,26,24,0.35);
}

.phone-screen {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: calc(31 * var(--p));
  background: #2a2a2a;
}
.phone-view {
  position: absolute;
  inset: 0;
}
.phone-view--photo::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0) 22%);
}
.phone-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}
.phone-island {
  position: absolute;
  z-index: 3;
  top: calc(9 * var(--p));
  left: 50%;
  width: calc(70 * var(--p));
  height: calc(20 * var(--p));
  border-radius: calc(12 * var(--p));
  background: #000;
  transform: translateX(-50%);
}
.phone-top {
  position: absolute;
  z-index: 2;
  top: calc(38 * var(--p));
  left: calc(12 * var(--p));
  right: calc(12 * var(--p));
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-size: calc(11 * var(--p));
  font-weight: 600;
}
.phone-close,
.phone-spacer {
  width: calc(26 * var(--p));
  height: calc(26 * var(--p));
}
.phone-close {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
}
.phone-close svg { width: calc(9 * var(--p)); }
.phone-pill {
  padding: calc(6 * var(--p)) calc(10 * var(--p));
  border-radius: calc(4 * var(--p));
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: calc(11 * var(--p));
  font-weight: 600;
  white-space: nowrap;
}
.phone-pill--float {
  position: absolute;
  z-index: 2;
  left: 50%;
  transform: translateX(-50%);
}

.viewfinder {
  position: absolute;
  z-index: 1;
}
.viewfinder b {
  position: absolute;
  width: calc(10 * var(--p));
  height: calc(10 * var(--p));
  border: 0 solid #fff;
}
.viewfinder b:nth-child(1) { top: 0; left: 0; border-top-width: calc(1.5 * var(--p)); border-left-width: calc(1.5 * var(--p)); }
.viewfinder b:nth-child(2) { top: 0; right: 0; border-top-width: calc(1.5 * var(--p)); border-right-width: calc(1.5 * var(--p)); }
.viewfinder b:nth-child(3) { bottom: 0; left: 0; border-bottom-width: calc(1.5 * var(--p)); border-left-width: calc(1.5 * var(--p)); }
.viewfinder b:nth-child(4) { bottom: 0; right: 0; border-bottom-width: calc(1.5 * var(--p)); border-right-width: calc(1.5 * var(--p)); }
.scan-line {
  position: absolute;
  left: calc(3 * var(--p));
  right: calc(3 * var(--p));
  top: 10%;
  height: calc(1.5 * var(--p));
  background: var(--red);
  box-shadow: 0 0 calc(8 * var(--p)) var(--red);
  animation: scan-sweep 2.6s ease-in-out infinite;
}
@keyframes scan-sweep {
  0%, 100% { top: 10%; }
  50%      { top: 86%; }
}

/* Softens the hard edge of a blurred plate into a frosted patch */
.frost {
  position: absolute;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent), linear-gradient(180deg, transparent, #000 26%, #000 74%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent), linear-gradient(180deg, transparent, #000 26%, #000 74%, transparent);
  mask-composite: intersect;
}

.shutter {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 4%;
  width: calc(40 * var(--p));
  height: calc(40 * var(--p));
  border-radius: 50%;
  box-shadow: inset 0 0 0 calc(3 * var(--p)) #fff;
  transform: translateX(-50%);
}
.shutter::after {
  content: '';
  position: absolute;
  inset: calc(6 * var(--p));
  border-radius: 50%;
  background: #fff;
}

.phone .plate--on-photo { z-index: 1; font-size: calc(var(--plate-p, 12) * var(--p)); }

/* Result sheet */
.sheet {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  padding: calc(14 * var(--p)) calc(14 * var(--p)) 0;
  border-radius: calc(16 * var(--p)) calc(16 * var(--p)) 0 0;
  background: var(--snow);
  color: var(--chocolate);
}
.sheet-grab {
  display: block;
  width: calc(34 * var(--p));
  height: calc(4 * var(--p));
  margin: calc(-6 * var(--p)) auto calc(10 * var(--p));
  border-radius: calc(2 * var(--p));
  background: rgba(69,48,46,0.2);
}
.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sheet-row .plate {
  width: calc(74 * var(--p));
  height: calc(20 * var(--p));
  padding: 0;
  font-size: calc(12 * var(--p));
}
.sheet-tag {
  padding: calc(4 * var(--p)) calc(7 * var(--p));
  border-radius: calc(3 * var(--p));
  background: var(--red);
  color: #fff;
  font-size: calc(10 * var(--p));
  font-weight: 600;
}
.sheet-pts {
  margin-top: calc(8 * var(--p));
  font-family: var(--font-heading);
  font-size: calc(40 * var(--p));
  line-height: 0.9;
}
.sheet-pts small {
  margin-left: calc(4 * var(--p));
  font-family: var(--font-body);
  font-size: calc(11 * var(--p));
  font-weight: 500;
  color: rgba(69,48,46,0.6);
}
.sheet-meta {
  margin-top: calc(3 * var(--p));
  font-size: calc(10.5 * var(--p));
  color: rgba(69,48,46,0.65);
}
.sheet-add {
  display: flex;
  height: calc(34 * var(--p));
  margin-top: calc(10 * var(--p));
  background: var(--chocolate);
  color: var(--snow);
  font-size: calc(11.5 * var(--p));
  font-weight: 500;
}
.sheet-add > span:first-child {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 calc(10 * var(--p));
}
.sheet-add-arrow {
  display: grid;
  place-items: center;
  width: calc(34 * var(--p));
  background: var(--red);
  color: #fff;
}
.sheet-add-arrow svg { width: calc(13 * var(--p)); height: auto; }

/* Archive list screen */
.phone-view--app {
  padding: calc(36 * var(--p)) calc(11 * var(--p)) 0;
  background: var(--snow);
  color: var(--chocolate);
}
.screen-title { font-size: calc(10.5 * var(--p)); font-weight: 600; }
.screen-total {
  margin-top: calc(5 * var(--p));
  font-family: var(--font-heading);
  font-size: calc(32 * var(--p));
  line-height: 0.85;
}
.screen-total small {
  margin-left: calc(3 * var(--p));
  font-family: var(--font-body);
  font-size: calc(8.5 * var(--p));
  font-weight: 500;
  color: rgba(69,48,46,0.6);
}
.screen-sub { margin-top: calc(3 * var(--p)); font-size: calc(7.5 * var(--p)); color: rgba(69,48,46,0.65); }
.screen-list { margin-top: calc(9 * var(--p)); border-top: 1px solid rgba(69,48,46,0.14); }
.screen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(22 * var(--p));
  border-bottom: 1px solid rgba(69,48,46,0.1);
}
.screen-row .plate { width: calc(48 * var(--p)); height: calc(12 * var(--p)); padding: 0; font-size: calc(7 * var(--p)); }
.screen-row b { font-family: var(--font-heading); font-weight: 400; font-size: calc(13 * var(--p)); line-height: 1; }
.screen-row.is-new b { color: var(--red); }
.screen-new {
  margin-right: calc(4 * var(--p));
  padding: calc(2 * var(--p)) calc(3 * var(--p));
  border-radius: calc(2 * var(--p));
  background: var(--red);
  color: #fff;
  font-family: var(--font-body);
  font-size: calc(6 * var(--p));
  font-weight: 600;
  vertical-align: calc(2 * var(--p));
}
.phone-view--app .sheet-add {
  position: absolute;
  left: calc(11 * var(--p));
  right: calc(11 * var(--p));
  bottom: calc(14 * var(--p));
  height: calc(26 * var(--p));
  margin: 0;
  font-size: calc(9 * var(--p));
}
.phone-view--app .sheet-add > span:first-child { padding: 0 calc(8 * var(--p)); }
.phone-view--app .sheet-add-arrow { width: calc(26 * var(--p)); }

/* A short press: buttons dip by a pixel */
.btn-split,
.btn-outline,
.btn-plate { transition: transform 0.12s var(--ease-out), box-shadow var(--ease-normal); }
.btn-split:active,
.btn-outline:active,
.btn-plate:active { transform: translateY(1px) scale(0.99); }

@media (prefers-reduced-motion: reduce) {
  .scan-line { animation: none; top: 48%; }
  .btn-split:active, .btn-outline:active, .btn-plate:active { transform: none; }
  .btn-split-arrow svg,
  .btn-plate { transition: none; }
}

/* Inline error under a form */
.error-msg {
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--red);
  background: rgba(200,16,46,0.06);
  font-size: 14px;
  line-height: 1.45;
  color: var(--chocolate);
}
.error-msg[hidden] { display: none; }

/* Rarity tiers, matching the colours in rarity.js */
.tier-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 6px;
  border-radius: 3px;
  font: 600 12px/1.2 var(--font-body);
  white-space: nowrap;
}
.tier-elite    { background: #C8102E; color: #fff; }
.tier-prestige { background: #45302E; color: #FEF8F5; }
.tier-rare     { background: #7C6C6A; color: #FEF8F5; }
.tier-uncommon { background: #E6DCD8; color: #45302E; }
.tier-standard { background: #EFE7E3; color: #45302E; }
.tier-common   { background: #F5EFEC; color: #45302E; box-shadow: inset 0 0 0 1px rgba(69,48,46,0.12); }

/* App screens share one page frame */
.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 92px 20px 112px;
}
.app-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
}
.app-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--red);
}
.app-heading {
  margin-top: 8px;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 64px;
  line-height: 0.86;
}
.app-section { margin-top: 48px; }
.app-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}
.app-section-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.select {
  height: 44px;
  padding: 0 34px 0 12px;
  border: 0;
  border-radius: 3px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2345302E' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  box-shadow: inset 0 0 0 1.5px var(--ink-line);
  font: 500 14px/1 var(--font-body);
  color: var(--chocolate);
  appearance: none;
  cursor: pointer;
}
.select:hover { box-shadow: inset 0 0 0 1.5px var(--chocolate); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.filters .select { flex: 1 1 140px; min-width: 0; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--chocolate);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}
.text-link svg { color: var(--red); transition: transform var(--ease-normal); }
.text-link:hover svg { transform: translateX(3px); }

.empty-state {
  padding: 32px 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.empty-state a { color: var(--chocolate); font-weight: 600; text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 3px; }

@media (min-width: 900px) {
  .app { padding: 120px 40px 136px; }
  .app-section-head .filters { width: auto; flex-wrap: nowrap; }
  .filters .select { flex: 0 1 200px; }
  .app-heading { font-size: 96px; }
}

/* Lists and grids rise in one after another when they are filled */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}
.stagger > * { animation: rise 0.7s var(--ease-out) both; }
.stagger > :nth-child(2)  { animation-delay: 60ms; }
.stagger > :nth-child(3)  { animation-delay: 120ms; }
.stagger > :nth-child(4)  { animation-delay: 180ms; }
.stagger > :nth-child(5)  { animation-delay: 240ms; }
.stagger > :nth-child(6)  { animation-delay: 300ms; }
.stagger > :nth-child(7)  { animation-delay: 360ms; }
.stagger > :nth-child(8)  { animation-delay: 420ms; }
.stagger > :nth-child(n+9) { animation-delay: 480ms; }

/* Placeholder blocks in the shape of the content, shown while it loads */
@keyframes shimmer {
  to { background-position: -200% 0; }
}
.skeleton,
.stats-row:empty::before,
.stats-row:empty::after,
.recent-grid:empty::before,
.recent-grid:empty::after,
.plate-grid:empty::before,
.plate-grid:empty::after {
  border-radius: 4px;
  background: linear-gradient(90deg, #EFE7E3 0%, #F7F1EE 50%, #EFE7E3 100%) 0 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.stats-row:empty::before,
.stats-row:empty::after { content: ''; height: 96px; margin-top: 18px; }
.recent-grid:empty::before,
.recent-grid:empty::after,
.plate-grid:empty::before,
.plate-grid:empty::after { content: ''; aspect-ratio: 4 / 3; }

/* Nothing archived yet */
.empty-block {
  grid-column: 1 / -1;
  display: grid;
  justify-items: start;
  gap: 18px;
  padding: 40px 0 8px;
}
.empty-block .plate {
  height: 40px;
  padding: 0 14px;
  font-size: 22px;
  color: rgba(17,17,17,0.35);
}
.empty-title {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 48px;
  line-height: 0.88;
}
.empty-text { max-width: 420px; font-size: 16px; line-height: 1.5; color: var(--ink-soft); }
.empty-text a { color: var(--chocolate); font-weight: 600; text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .stagger > * { animation: none; }
  .skeleton,
  .stats-row:empty::before, .stats-row:empty::after,
  .recent-grid:empty::before, .recent-grid:empty::after,
  .plate-grid:empty::before, .plate-grid:empty::after { animation: none; }
}
