/* FatLogs main UI: 1970s national-park campground. See DESIGN.md. */

:root {
  --pine: #1f3b2d;
  --cream: #f3e9d2;
  --ember: #d9612b;
  --mustard: #e3a73b;
  --bark: #3b2416;
  --bark-2: #6b4226;
  --sky: #20303f;
  --ash: #8a8170;

  --paper: #faf3e2;
  --ink: var(--bark);
  --line: 3px solid var(--bark);
  --shadow: 4px 4px 0 var(--bark);
  --radius: 8px;

  --f-head: "Bowlby One", "Arial Black", Impact, sans-serif;
  --f-body: "Fraunces", Georgia, "Times New Roman", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --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='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .23 0 0 0 0 .14 0 0 0 0 .09 0 0 0 .55 -.18'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --bar-h: 84px;
}

*, *::before, *::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--cream);
  background-image: var(--grain);
  color: var(--ink);
  font-family: var(--f-body);
  font-optical-sizing: auto;
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
}

img { max-width: 100%; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 400; line-height: 1.05; margin: 0; }
p { margin: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.2em;
}
.icon .solid, .icon-solid { fill: currentColor; stroke: none; }

:focus-visible { outline: 3px solid var(--ember); outline-offset: 2px; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-t)) max(16px, var(--safe-r)) calc(var(--bar-h) + 24px + var(--safe-b)) max(16px, var(--safe-l));
}

/* ---------- Buttons: painted signs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  font-family: var(--f-head); font-size: 17px; letter-spacing: 0.02em; line-height: 1;
  color: var(--bark); background: var(--paper);
  border: var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform .08s ease-out, box-shadow .08s ease-out;
  text-decoration: none;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--bark); }
.btn:disabled { opacity: .55; cursor: default; transform: none; box-shadow: var(--shadow); }
.btn-ember { background: var(--ember); color: var(--paper); }
.btn-mustard { background: var(--mustard); color: var(--bark); }
.btn-pine { background: var(--pine); color: var(--cream); }
.btn-cream { background: var(--cream); }
.btn-plain { background: var(--paper); }
.btn-small { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.btn-block { display: flex; width: 100%; }
.btn-big { font-size: 22px; min-height: 58px; }
.btn-text {
  background: none; border: 0; padding: 10px 8px; cursor: pointer;
  font-family: var(--f-mono); font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
  color: var(--bark);
}

/* ---------- Header: the park sign ---------- */
.site-head { margin: 0 auto 26px; max-width: 640px; text-align: center; }
.sign {
  position: relative;
  background: var(--pine);
  color: var(--cream);
  border: var(--line);
  border-radius: 10px;
  box-shadow: 5px 5px 0 var(--bark);
  padding: 18px 16px 0;
  overflow: hidden;
}
.sign::before { /* routed inner border */
  content: ""; position: absolute; inset: 6px 6px 22px;
  border: 2px solid rgba(243, 233, 210, .55); border-radius: 6px; pointer-events: none;
}
.sign-trees { display: block; width: 84px; height: 28px; margin: 0 auto 6px; fill: var(--mustard); }
.sign-trees .trunk { fill: var(--cream); }
.kicker {
  font-family: var(--f-mono); font-weight: 600; font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--mustard);
}
.wordmark {
  font-size: clamp(48px, 15vw, 84px);
  letter-spacing: 0.01em;
  color: var(--cream);
  text-shadow: 3px 3px 0 var(--ember);
  margin: 4px 0 18px;
}
.stripes { display: flex; flex-direction: column; margin: 0 -16px; }
.stripes i { display: block; height: 7px; }
.stripes i:nth-child(1) { background: var(--mustard); }
.stripes i:nth-child(2) { background: var(--ember); }
.stripes i:nth-child(3) { background: var(--bark-2); }
.tagline { margin: 14px 8px 0; font-style: italic; font-size: 17px; }

.section-label {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--f-mono); font-weight: 600; font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--bark-2); margin: 0 0 14px;
}
.section-label::before, .section-label::after { content: ""; flex: 1; border-top: 2px dashed var(--bark-2); opacity: .6; }

/* ---------- LEGENDARY patch ---------- */
.patch {
  position: relative;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 11px 5px;
  font-family: var(--f-head); font-size: 12px; letter-spacing: .1em; line-height: 1;
  color: var(--pine); background: var(--mustard);
  border: 3px solid var(--pine); border-radius: 7px;
  box-shadow: 2px 2px 0 var(--bark);
}
.patch::after { /* stitching */
  content: ""; position: absolute; inset: 2px;
  border: 1.5px dashed var(--pine); border-radius: 4px; pointer-events: none;
}
.patch .icon { width: 10px; height: 10px; vertical-align: 0; }
.patch-lg {
  font-size: clamp(22px, 7vw, 30px); padding: 14px 22px 12px; gap: 10px;
  border-width: 4px; border-radius: 12px; box-shadow: 4px 4px 0 var(--bark);
  transform: rotate(-3deg);
}
.patch-lg::after { inset: 4px; border-width: 2px; border-radius: 7px; }
.patch-lg .icon { width: 16px; height: 16px; }

/* ---------- Bristol chip ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 9px 4px 6px; min-height: 30px;
  font-family: var(--f-mono); font-size: 12px; line-height: 1.2; text-align: left;
  color: var(--bark); background: var(--cream);
  border: 2px solid var(--bark); border-radius: 6px;
}
button.chip { cursor: pointer; }
button.chip:hover { background: #efe0bd; }
.chip .bshape { width: 30px; height: 13px; flex: none; }

/* ---------- Feed ---------- */
.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
  gap: 22px;
  align-items: start;
}
.feed-status { grid-column: 1 / -1; text-align: center; font-family: var(--f-mono); font-size: 13px; color: var(--ash); padding: 40px 0; }

.card {
  background: var(--paper);
  border: var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.card-photo { position: relative; border-bottom: var(--line); background: var(--bark-2); aspect-ratio: 1 / 1; }
.card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-photo .patch { position: absolute; left: 10px; top: 10px; transform: rotate(-4deg); }
.card-body { padding: 12px 14px 10px; }
.card-body h3 { font-size: 21px; margin: 10px 0 6px; overflow-wrap: anywhere; }
.card-body p { font-size: 15.5px; overflow-wrap: anywhere; }
.meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px;
  margin-top: 12px; padding-top: 8px; border-top: 2px dashed rgba(59, 36, 22, .25);
  font-family: var(--f-mono); font-size: 12px; color: var(--bark-2);
}
.meta .stat { display: inline-flex; align-items: center; gap: 4px; }
.meta .grow { flex: 1; color: var(--ash); }
.meta button {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 0; padding: 8px 2px; min-height: 36px; cursor: pointer;
  font-family: var(--f-mono); font-size: 12px; color: var(--bark-2);
}
.meta button:hover { color: var(--ember); }
.meta button.armed { color: var(--paper); background: var(--ember); padding: 6px 8px; border-radius: 5px; }
.meta button:disabled { cursor: default; color: var(--ash); }

.feed-empty { text-align: center; padding: 30px 12px 10px; }
.feed-empty .swirl { width: 104px; height: 104px; }
.feed-empty h3 { font-size: 24px; margin: 10px 0 6px; }
.feed-empty p { color: var(--bark-2); }

.more { display: flex; margin: 30px auto 0; }
.more[hidden] { display: none; }

/* ---------- Footer ---------- */
.site-foot {
  margin: 44px auto 0; max-width: 720px;
  padding: 18px 18px 16px;
  background: var(--pine); color: var(--cream);
  border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 14px; line-height: 1.55;
}
.site-foot strong { color: var(--mustard); font-weight: 600; }
.foot-mark { margin-top: 12px; font-family: var(--f-mono); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--mustard); }

/* ---------- Bottom bar ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--pine);
  border-top: var(--line);
  padding: 12px max(16px, var(--safe-r)) calc(12px + var(--safe-b)) max(16px, var(--safe-l));
}
.bar-inner { display: flex; gap: 12px; max-width: 560px; margin: 0 auto; }
.bar .btn { box-shadow: 4px 4px 0 #0d1a13; border-color: #0d1a13; }
.bar .btn:active { box-shadow: 1px 1px 0 #0d1a13; }
.bar .btn-big { flex: 1; }

/* ---------- Overlays + sheets ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: none; align-items: flex-end; justify-content: center;
  background: rgba(16, 28, 21, .66);
  padding-top: var(--safe-t);
}
.overlay.open { display: flex; }
.overlay-top { z-index: 45; }

.sheet {
  position: relative;
  width: 100%; max-width: 560px;
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background-color: var(--paper); background-image: var(--grain);
  border: var(--line); border-bottom: 0;
  border-radius: 12px 12px 0 0;
  padding: 10px max(18px, var(--safe-r)) calc(22px + var(--safe-b)) max(18px, var(--safe-l));
  text-align: center;
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(36px); opacity: 0; } }
.grip { width: 44px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: var(--bark); opacity: .35; }
.sheet-title { font-size: 28px; margin: 4px 0 8px; }
.sheet-lede { margin: 0 auto 18px; max-width: 34ch; color: var(--bark-2); }
.sheet .btn-block + .btn-block { margin-top: 14px; }
.fine { margin: 16px auto 0; max-width: 46ch; font-family: var(--f-mono); font-size: 11.5px; line-height: 1.5; color: var(--bark-2); }
.sheet-close { position: absolute; top: 10px; right: 10px; }

.preview {
  display: block; width: 100%; max-height: 46vh; object-fit: contain;
  margin: 4px 0 18px; background: var(--bark);
  border: var(--line); border-radius: var(--radius);
}

.judging { padding: 18px 0 8px; }
.judging .swirl { width: 112px; height: 112px; animation: wobble 1.1s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) translateY(-4px); } }
.dots::after { content: ""; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.verdict { padding-top: 10px; }
.verdict .patch-lg { margin: 6px 0 18px; }
.verdict h2 { font-size: clamp(24px, 7vw, 32px); margin: 14px 0 10px; overflow-wrap: anywhere; }
.verdict p.review { font-size: 17px; margin-bottom: 20px; overflow-wrap: anywhere; }
.reject-reason {
  margin: 4px 0 20px; padding: 12px 14px; text-align: left;
  background: var(--cream); border: 2px dashed var(--bark-2); border-radius: 6px;
  overflow-wrap: anywhere;
}

/* Bristol chart */
.chart-list { list-style: none; margin: 8px 0 0; padding: 0; text-align: left; }
.chart-list li {
  display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 4px 12px;
  padding: 9px 10px; margin: 0 0 6px;
  border: 2px solid transparent; border-radius: 6px;
}
.chart-list li .bshape { width: 56px; height: 24px; grid-row: span 2; }
.chart-list .t { font-family: var(--f-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--bark-2); }
.chart-list .l { font-size: 16px; }
.chart-list li.on { background: var(--mustard); border-color: var(--bark); box-shadow: 3px 3px 0 var(--bark); }
.chart-list li.on .t { color: var(--bark); }
.chart-list .tag { margin-left: 8px; padding: 1px 6px; border-radius: 4px; background: var(--pine); color: var(--cream); letter-spacing: .08em; }

.bshape .b-fill { fill: var(--bark-2); stroke: var(--bark); stroke-width: 2; stroke-linejoin: round; }
.bshape .b-line { fill: none; stroke: var(--bark); stroke-width: 2; stroke-linecap: round; }
.bshape .b-snake-o { fill: none; stroke: var(--bark); stroke-width: 10; stroke-linecap: round; }
.bshape .b-snake-i { fill: none; stroke: var(--bark-2); stroke-width: 6; stroke-linecap: round; }

/* ---------- Swipe modal ---------- */
.swipe {
  position: fixed; inset: 0; z-index: 40;
  display: none; flex-direction: column;
  background-color: var(--pine); background-image: var(--grain);
  padding: calc(10px + var(--safe-t)) max(16px, var(--safe-r)) calc(14px + var(--safe-b)) max(16px, var(--safe-l));
  color: var(--cream);
  overscroll-behavior: contain;
}
.swipe.open { display: flex; }
.swipe-top { display: flex; align-items: center; gap: 14px; max-width: 480px; width: 100%; margin: 0 auto 12px; }
.swipe-top .btn { border-color: #0d1a13; box-shadow: 3px 3px 0 #0d1a13; }
.swipe-title { font-size: 22px; color: var(--cream); text-shadow: 2px 2px 0 var(--ember); }

.deck { position: relative; flex: 1; min-height: 0; width: 100%; max-width: 480px; margin: 0 auto; }
.scard {
  position: absolute; inset: 0 0 10px;
  display: flex; flex-direction: column;
  background: var(--paper); color: var(--bark);
  border: var(--line); border-radius: 10px;
  box-shadow: 5px 5px 0 #0d1a13;
  overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
  transition: transform .26s ease-out;
  will-change: transform;
}
.scard.dragging { transition: none; cursor: grabbing; }
.scard.behind { transform: scale(.95) translateY(14px); pointer-events: none; }
.deck.dragging .scard.behind { transition: none; }
.scard[data-gone] { pointer-events: none; }
.scard-photo { position: relative; flex: 1; min-height: 0; background: var(--bark-2); border-bottom: var(--line); }
.scard-photo img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.scard-body { padding: 12px 16px 16px; }
.scard-body .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.scard-body h3 { font-size: 22px; margin: 10px 0 4px; overflow-wrap: anywhere; }
.scard-body p { font-size: 15px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.stamp {
  position: absolute; top: 22px;
  padding: 6px 14px 4px;
  font-family: var(--f-head); font-size: 36px; letter-spacing: .06em; line-height: 1;
  border: 5px solid; border-radius: 8px;
  background: rgba(250, 243, 226, .88);
  opacity: 0; pointer-events: none;
}
.stamp.like { left: 18px; color: var(--pine); transform: rotate(-12deg); }
.stamp.nope { right: 18px; color: var(--ember); transform: rotate(12deg); }

.deck-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 0 16px;
}
.deck-msg .swirl { width: 110px; height: 110px; }
.deck-msg h3 { font-size: 26px; color: var(--cream); }
.deck-msg p { color: #d8ccb0; }
.deck-msg .btn { margin-top: 10px; }
.deck-loading { font-family: var(--f-mono); font-size: 13px; color: #d8ccb0; }

.swipe-actions { display: flex; justify-content: center; gap: 16px; padding-top: 14px; max-width: 480px; width: 100%; margin: 0 auto; }
.vote-btn { flex: 1; max-width: 200px; min-height: 58px; font-size: 20px; border-color: #0d1a13; box-shadow: 4px 4px 0 #0d1a13; }
.vote-btn:active { box-shadow: 1px 1px 0 #0d1a13; }
.vote-btn .icon { width: 24px; height: 24px; stroke-width: 3; }
.vote-nope { color: var(--ember); }
.vote-like { color: var(--pine); }

/* ---------- Swirl character ---------- */
.swirl { display: inline-block; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(var(--bar-h) + 18px + var(--safe-b));
  max-width: min(92vw, 420px); width: max-content;
  padding: 10px 14px;
  font-family: var(--f-mono); font-size: 13px; line-height: 1.4; text-align: center;
  color: var(--cream); background: var(--bark);
  border: 2px solid var(--cream); border-radius: 6px;
  box-shadow: 3px 3px 0 var(--ember);
  opacity: 0; visibility: hidden;
  transform: translate(-50%, 10px);
  transition: opacity .2s, transform .2s, visibility 0s linear .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .2s, transform .2s; }

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet {
    border-bottom: var(--line); border-radius: 12px;
    box-shadow: 6px 6px 0 var(--bark);
    max-height: 88vh;
    padding: 14px 26px 26px;
  }
  .grip { display: none; }
  .tagline { font-size: 19px; }
  .swipe { padding-top: calc(20px + var(--safe-t)); padding-bottom: calc(24px + var(--safe-b)); }
}

@media (hover: hover) {
  .btn:hover { filter: brightness(1.05); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .judging .swirl { animation: none; }
}
