/* ---- Tokens: deli-ticket palette ---- */
:root {
  --paper: #FCF5E8;        /* bread-white */
  --paper-deep: #F3E8D2;
  --ink: #2B1D12;          /* dark rye */
  --ink-soft: #6B584A;
  --mustard: #E8A400;
  --butter: #FFD966;
  --tomato: #D9482B;
  --lettuce: #5E8C3A;
  --card: #FFFDF8;
  --line: #E2D3BA;

  /* the authentic meme ramp — do not tastefully redesign the meme */
  --tier-S: #FF7F7F;
  --tier-A: #FFBF7F;
  --tier-B: #FFDF7F;
  --tier-C: #FFFF7F;
  --tier-D: #BFFF7F;
  --tier-F: #7FBF7F;

  --display: 'Alfa Slab One', serif;
  --body: 'Karla', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  background-image: repeating-linear-gradient(0deg, transparent 0 34px, rgba(43, 29, 18, 0.03) 34px 35px);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: var(--body); cursor: pointer; }

/* ---- Sign-in ---- */
.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.signin-ticket {
  position: relative;
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 48px 40px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.ticket-edge {
  position: absolute;
  top: -2px; left: -2px; right: -2px;
  height: 10px;
  background: repeating-linear-gradient(90deg, var(--tomato) 0 16px, var(--card) 16px 32px);
  border-bottom: 2px solid var(--ink);
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 8px 0 4px;
}

.signin-title {
  font-family: var(--display);
  font-size: clamp(44px, 10vw, 64px);
  line-height: 0.95;
  margin: 8px 0 12px;
  text-transform: uppercase;
}

.signin-sub { color: var(--ink-soft); margin: 0 0 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--ink);
  background: var(--butter);
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  padding: 12px 22px;
  box-shadow: 3px 3px 0 var(--ink);
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible, .tab:focus-visible, .stamp:focus-visible {
  outline: 3px solid var(--tomato);
  outline-offset: 2px;
}

.btn-secondary { background: var(--card); }
.signin-fineprint { font-size: 12px; color: var(--ink-soft); margin-top: 20px; }

/* ---- Masthead ---- */
.app { max-width: 760px; margin: 0 auto; padding: 0 16px 60px; }

.masthead { padding-top: 28px; }

.masthead-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.masthead h1 {
  font-family: var(--display);
  font-size: clamp(30px, 6vw, 44px);
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
}

.masthead-tag {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--ink);
  background: var(--card);
  padding: 6px 12px 6px 6px;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 2px 2px 0 var(--ink);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  object-fit: cover;
  background: var(--mustard);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex: none;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 8px;
  margin: 24px 0 20px;
  border-bottom: 2px solid var(--ink);
}

.tab {
  border: 2px solid var(--ink);
  border-bottom: none;
  background: var(--paper-deep);
  font-weight: 800;
  font-size: 15px;
  padding: 10px 18px 8px;
  color: var(--ink-soft);
  translate: 0 2px;
}

.tab.active {
  background: var(--card);
  color: var(--ink);
  padding-bottom: 12px;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-family: var(--display);
  font-size: 22px;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.date-line {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.sandwich-name {
  font-family: var(--display);
  font-size: clamp(26px, 5vw, 36px);
  line-height: 1.05;
  margin: 0 0 4px;
}

.edit-link {
  font-family: var(--body);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-bottom: 2px dotted var(--ink-soft);
  padding: 0 0 1px;
  margin-left: 8px;
  vertical-align: middle;
}

.edit-link:hover { color: var(--tomato); border-color: var(--tomato); }

.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

/* ---- Tier vote stamps ---- */
.stamp-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 16px 0 4px;
}

.stamp {
  border: 2px solid var(--ink);
  font-family: var(--display);
  font-size: 26px;
  padding: 10px 0 8px;
  background: var(--paper-deep);
  color: var(--ink);
  opacity: 0.55;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.08s ease, opacity 0.08s ease;
}

.stamp:hover { opacity: 0.85; transform: translateY(-2px); }

.stamp.selected {
  opacity: 1;
  transform: rotate(-3deg) scale(1.08);
  box-shadow: 3px 3px 0 var(--ink);
}

.stamp[data-tier="S"] { background: var(--tier-S); }
.stamp[data-tier="A"] { background: var(--tier-A); }
.stamp[data-tier="B"] { background: var(--tier-B); }
.stamp[data-tier="C"] { background: var(--tier-C); }
.stamp[data-tier="D"] { background: var(--tier-D); }
.stamp[data-tier="F"] { background: var(--tier-F); }

.voters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  min-height: 30px;
}

.voter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  padding: 2px 10px 2px 3px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
}

.voter .tier-pip {
  font-family: var(--display);
  font-size: 13px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.verdict {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 14px;
  padding: 6px 14px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-weight: 800;
}

.verdict .big-tier { font-family: var(--display); font-size: 28px; }

/* ---- Photos ---- */
.photo-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
}

.photo-thumb {
  position: relative;
  width: 110px;
  height: 110px;
  border: 2px solid var(--ink);
  background: var(--paper-deep);
  padding: 0;
  overflow: hidden;
  box-shadow: 2px 2px 0 var(--ink);
  transform: rotate(-1.2deg);
}

.photo-thumb:nth-child(even) { transform: rotate(1.4deg); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.add-photo {
  width: 110px;
  height: 110px;
  border: 2px dashed var(--ink-soft);
  background: transparent;
  color: var(--ink-soft);
  font-weight: 800;
  font-size: 13px;
}

.add-photo:hover { border-color: var(--ink); color: var(--ink); }

/* ---- Log-lunch form ---- */
.field { margin: 14px 0; }
.field label { display: block; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }

select, input[type="text"] {
  width: 100%;
  font-family: var(--body);
  font-size: 16px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
}

.or-divider {
  text-align: center;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  margin: 10px 0;
}

/* ---- Tier list ---- */
.tier-board { border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); margin-bottom: 20px; }

.tier-row { display: flex; border-bottom: 2px solid var(--ink); background: #3a3a3a; }
.tier-row:last-child { border-bottom: none; }

.tier-label {
  flex: none;
  width: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 36px;
  color: var(--ink);
  border-right: 2px solid var(--ink);
}

.tier-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  min-height: 84px;
  align-items: center;
}

.tier-card {
  width: 92px;
  border: 2px solid var(--ink);
  background: var(--card);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--body);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  padding: 0;
  color: var(--ink);
  transition: transform 0.08s ease;
}

.tier-card:hover { transform: translateY(-2px); }

.tier-card .tier-card-img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  display: block;
  border-bottom: 1.5px solid var(--ink);
  background: var(--paper-deep);
  font-size: 30px;
  line-height: 64px;
}

.tier-card .tier-card-name { padding: 4px 4px 1px; line-height: 1.2; }
.tier-card .tier-card-meta { padding: 0 4px 4px; color: var(--ink-soft); font-weight: 600; font-size: 10px; }

.tier-empty { color: rgba(255, 255, 255, 0.55); font-size: 12px; font-weight: 600; padding-left: 4px; }

.unranked-note { margin: 0 0 20px; }

/* ---- History ---- */
.history-card .photo-thumb { width: 84px; height: 84px; }

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.history-tier {
  font-family: var(--display);
  font-size: 30px;
  flex: none;
  width: 52px;
  height: 52px;
  border: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 var(--ink);
  transform: rotate(2deg);
}

.tier-bg-S { background: var(--tier-S); }
.tier-bg-A { background: var(--tier-A); }
.tier-bg-B { background: var(--tier-B); }
.tier-bg-C { background: var(--tier-C); }
.tier-bg-D { background: var(--tier-D); }
.tier-bg-F { background: var(--tier-F); }
.tier-bg-none { background: var(--paper-deep); color: var(--ink-soft); font-size: 16px; }

/* ---- Empty states, misc ---- */
.empty {
  text-align: center;
  padding: 40px 20px;
}

.empty .empty-emoji { font-size: 44px; display: block; margin-bottom: 8px; }

.error-note { color: var(--tomato); font-weight: 800; margin-top: 10px; }

.footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  margin-top: 40px;
}

/* ---- Sandwich dossier: Top Trumps card ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(43, 29, 18, 0.75);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.trump-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.35);
  width: min(430px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 14px;
}

.trump-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--butter);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.trump-title {
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.15;
  text-transform: uppercase;
}

.trump-tier {
  font-family: var(--display);
  font-size: 22px;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--paper-deep);
  scrollbar-width: none;
}

.carousel::-webkit-scrollbar { display: none; }

.slide {
  flex: none;
  width: 100%;
  scroll-snap-align: center;
  position: relative;
  margin: 0;
}

.slide img { width: 100%; height: 250px; object-fit: cover; display: block; }

.slide figcaption {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 999px;
}

.slide-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 250px;
  width: 100%;
  font-size: 64px;
}

.carousel-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.car-btn {
  border: 2px solid var(--ink);
  background: var(--card);
  width: 34px;
  height: 34px;
  font-size: 18px;
  font-weight: 800;
  border-radius: 50%;
  box-shadow: 2px 2px 0 var(--ink);
}

.trump-stats { margin: 14px 0; }

.trump-stats > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 2px;
  border-bottom: 2px dotted var(--line);
}

.trump-stats dt {
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.trump-stats dd { margin: 0; font-weight: 800; }

.record-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1.5px solid var(--line);
}

.record-row:last-child { border-bottom: none; }
.record-date { flex: none; width: 96px; font-weight: 800; font-size: 13px; }
.record-votes { flex: 1; display: flex; gap: 4px; flex-wrap: wrap; }

.record-votes .tier-pip {
  font-family: var(--display);
  font-size: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.record-tier {
  flex: none;
  font-family: var(--display);
  font-size: 15px;
  width: 30px;
  height: 30px;
  border: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(43, 29, 18, 0.88);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
  cursor: zoom-out;
}

.lightbox {
  flex-direction: column;
  gap: 16px;
}

.lightbox:not(.hidden) { display: flex; align-items: center; justify-content: center; }

.lightbox img {
  max-width: 100%;
  max-height: 82vh;
  border: 3px solid var(--card);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.4);
}

.btn-danger { background: var(--tomato); color: #fff; }

@media (max-width: 540px) {
  .tier-label { width: 52px; font-size: 26px; }
  .tier-card { width: 80px; }
  .stamp { font-size: 20px; }
  .masthead-tag { display: none; }
}

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