/* ============================================================
   FAT ANIME — design system
   Everything slightly overinflated: chunky type, sticker cards,
   hard offset shadows, squish-on-press.
   ============================================================ */

:root {
  --bg: #FFF6E9;
  --card: #FFFDF7;
  --ink: #1A1A1A;
  --pink: #FF3E6C;
  --orange: #FFA928;
  --yellow: #FFC53D;
  --radius: 18px;
  --border: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --font-display: "Titan One", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --tabbar-h: 74px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

/* author display rules must never beat the hidden attribute */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.45;
  overscroll-behavior-y: none;
}

img { display: block; max-width: 100%; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* The whole app is a phone column, even on desktop (Instagram-web style) */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  position: relative;
}

/* subtle halftone dots behind everything */
.app::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(var(--ink) 1px, transparent 1.3px);
  background-size: 20px 20px;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}

.app > * { position: relative; z-index: 1; }

/* ---------- type ---------- */

.display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.01em;
}

.wordmark {
  font-family: var(--font-display);
  font-size: clamp(40px, 12vw, 52px);
  margin: 6px 0 4px;
  text-align: center;
  color: var(--pink);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-1.5deg);
}

.wordmark .alt { color: var(--yellow); }

.section-title {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 26px 2px 12px;
  transform: rotate(-1deg);
}

/* ---------- sticker primitives ---------- */

.sticker {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  font-family: var(--font-display);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border: var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  background: var(--pink);
  color: #fff;
  -webkit-text-stroke: 1px var(--ink);
  paint-order: stroke fill;
  text-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.15s var(--spring), box-shadow 0.15s var(--spring);
  user-select: none;
  text-decoration: none;
}

.btn:active {
  transform: translate(3px, 3px) scale(0.93);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn.orange { background: var(--orange); }
.btn.ghost { background: var(--card); color: var(--ink); text-shadow: none; -webkit-text-stroke: 0; }
.btn.big { width: 100%; font-size: 24px; padding: 18px 22px; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }

.squish { transition: transform 0.15s var(--spring); }
.squish:active { transform: scale(0.93); }

/* ---------- counter pill ---------- */

.slots-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-weight: 800;
  font-size: 15px;
  border-radius: 999px;
  background: var(--card);
  border: var(--border);
  box-shadow: var(--shadow-sm);
}

.slots-pill .num { color: var(--pink); font-size: 18px; }

/* ---------- hero ---------- */

.hero {
  margin-top: 14px;
  overflow: hidden;
  position: relative;
  border-radius: var(--radius);
}

.hero .frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--ink);
}

.hero video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- chips ---------- */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

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

.chip {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 14px;
  padding: 8px 14px;
  border: var(--border);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--spring);
  white-space: nowrap;
}

.chip:active { transform: scale(0.93); }

.chip.active {
  background: var(--pink);
  color: #fff;
  -webkit-text-stroke: 0.5px var(--ink);
  paint-order: stroke fill;
}

/* ---------- gallery grid ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.card {
  overflow: hidden;
  padding: 0;
  text-align: left;
  display: block;
  width: 100%;
}

.card .thumb {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
  background: var(--bg);
}

.card .label {
  font-family: var(--font-display);
  font-size: 14px;
  padding: 8px 10px;
  border-top: var(--border);
  background: var(--card);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pop { animation: pop 0.35s var(--spring) both; }

/* ---------- detail modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(26, 26, 26, 0.6);
  backdrop-filter: blur(3px);
}

.modal[hidden] { display: none; }

.sheet {
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 14px;
  touch-action: pan-y;
}

.sheet .stage {
  position: relative;
  aspect-ratio: 1 / 1;
  border: var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
}

.stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.stage img.after { opacity: 0; }
.stage.fat img.after { opacity: 1; animation: inflate 0.4s var(--spring); }
.stage.fat img.before { opacity: 0; }

.tap-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) rotate(-2deg);
  font-family: var(--font-display);
  font-size: 17px;
  background: var(--yellow);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 8px 14px;
  pointer-events: none;
  animation: bounce 1.6s ease-in-out infinite;
}

.sheet .meta { display: flex; align-items: baseline; gap: 8px; margin: 12px 2px 4px; }
.sheet .meta .name { font-family: var(--font-display); font-size: 22px; }
.sheet .meta .series { font-weight: 600; font-size: 13px; opacity: 0.6; }

.sheet .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.modal .close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  font-size: 18px;
  z-index: 2;
}

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1fr 1fr;
  background: var(--card);
  border-top: var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.03em;
  opacity: 0.55;
  transition: transform 0.15s var(--spring), opacity 0.15s;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}

.tab:active { transform: scale(0.9); }
.tab.active { opacity: 1; color: var(--pink); }
.tab svg { width: 26px; height: 26px; }

.tab.fatten {
  opacity: 1;
  margin-top: -30px;
  color: var(--ink);
}

.tab.fatten .fatten-label { font-size: 8.5px; letter-spacing: 0.02em; }

.tab.fatten .bubble {
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  border: var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--spring);
}

.tab.fatten:active .bubble { transform: scale(0.9); }
.tab.fatten.active .bubble { transform: scale(1.06); }

/* ---------- placeholder / empty states ---------- */

.placeholder {
  padding: 26px 20px;
  text-align: center;
  margin-top: 18px;
}

.placeholder .big-emoji { font-size: 52px; }
.placeholder h2 { font-family: var(--font-display); font-size: 22px; margin: 10px 0 6px; }
.placeholder p { margin: 0; font-weight: 600; opacity: 0.7; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  border: 3px solid var(--card);
  box-shadow: var(--shadow-sm);
  animation: pop 0.3s var(--spring) both;
  max-width: calc(100% - 40px);
  text-align: center;
}

/* ---------- generator ---------- */

.slots-pill.gen { margin-top: 14px; font-size: 16px; }

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  margin-top: 16px;
  border-radius: 16px;
}

.mode {
  font-family: var(--font-display);
  font-size: 15px;
  padding: 11px 8px;
  border-radius: 11px;
  border: 3px solid transparent;
  transition: transform 0.15s var(--spring);
}

.mode:active { transform: scale(0.95); }

.mode.active {
  background: var(--yellow);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.mode-hint {
  margin: 8px 4px 0;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.6;
  text-align: center;
}

.dropzone {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 38px 20px;
  margin-top: 16px;
  border-style: dashed;
  background: var(--card);
  transition: transform 0.15s var(--spring);
}

.dropzone:active { transform: scale(0.97); }
.dropzone .big-emoji { font-size: 44px; }
.dropzone .dz-title { font-family: var(--font-display); font-size: 22px; }
.dropzone .dz-sub { font-size: 13px; font-weight: 600; opacity: 0.6; }

.preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.preview-wrap img {
  max-height: 320px;
  border-radius: var(--radius);
  object-fit: contain;
}

#btn-generate { margin-top: 14px; }

.fineprint {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.45;
  margin: 10px 0 0;
}

.result-card {
  margin-top: 16px;
  overflow: hidden;
  padding: 0;
}

.result-card img { width: 100%; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* sold-out */

.countdown {
  font-family: var(--font-display);
  font-size: 44px;
  margin-top: 12px;
  color: var(--pink);
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--ink);
  font-variant-numeric: tabular-nums;
}

.notify {
  margin-top: 16px;
  padding: 16px;
}

.notify label { font-family: var(--font-display); font-size: 16px; display: block; margin-bottom: 10px; }

.notify .row { display: flex; gap: 8px; }

.notify input {
  flex: 1;
  min-width: 0;
  /* 16px minimum: anything smaller makes iOS Safari zoom/pan on focus */
  font: 600 16px var(--font-body);
  padding: 12px 14px;
  border: var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
}

.notify input:focus { outline: 3px solid var(--orange); outline-offset: 1px; }
.notify .btn { font-size: 15px; padding: 12px 16px; }

/* ---------- videos ---------- */

.video-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.video-card { overflow: hidden; padding: 0; }

.video-card video {
  display: block;
  width: 100%;
  background: var(--ink);
}

.video-card .label {
  font-family: var(--font-display);
  font-size: 15px;
  padding: 9px 12px;
  border-top: var(--border);
}

/* ---------- requests board ---------- */

.request-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.request-form input {
  flex: 1;
  min-width: 0;
  /* 16px minimum: anything smaller makes iOS Safari zoom/pan on focus */
  font: 600 16px var(--font-body);
  padding: 12px 14px;
  border: var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
}

.request-form input:focus { outline: 3px solid var(--orange); outline-offset: 1px; }
.request-form .btn { font-size: 15px; padding: 12px 16px; }

.request-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.request-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
}

.request-text {
  flex: 1;
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.25;
  word-break: break-word;
}

.vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 15px;
  padding: 9px 14px;
  border: var(--border);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.vote-btn.voted {
  background: var(--pink);
  color: #fff;
  -webkit-text-stroke: 0.5px var(--ink);
  paint-order: stroke fill;
  opacity: 1;
}

.vote-btn .count { min-width: 1.2em; text-align: center; }
.vote-btn .count.bump { animation: bump 0.35s var(--spring); }

@keyframes bump {
  0% { transform: scale(1); }
  50% { transform: scale(1.55) rotate(6deg); }
  100% { transform: scale(1); }
}

/* full-screen loading: the wait is part of the joke */

.loading {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px;
  background: var(--bg);
}

.loading[hidden] { display: none; }

.loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--ink) 1px, transparent 1.3px);
  background-size: 20px 20px;
  opacity: 0.05;
}

/* the wait is a show: presets inflate while a striped bar fills */

.load-stage {
  position: relative;
  width: min(72vw, 300px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  padding: 0;
}

.load-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.load-stage img.after { opacity: 0; }
.load-stage.fat img.after { opacity: 1; animation: inflate 0.4s var(--spring); }
.load-stage.fat img.before { opacity: 0; }

.loadbar {
  width: min(80vw, 340px);
  height: 30px;
  border-radius: 999px;
  padding: 3px;
  overflow: hidden;
}

.loadbar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.35) 0 10px, transparent 10px 20px),
    linear-gradient(90deg, var(--pink), var(--orange));
  background-size: 28px 100%, 100% 100%;
  animation: stripes 0.7s linear infinite;
  transition: width 0.35s linear;
}

@keyframes stripes {
  to { background-position: 28px 0, 0 0; }
}

.loading-caption {
  font-family: var(--font-display);
  font-size: 26px;
  animation: pop 0.3s var(--spring);
}

.loading-sub { font-size: 13px; font-weight: 600; opacity: 0.55; margin: 0; }

/* ---------- keyframes ---------- */



@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.05); opacity: 1; }
  80% { transform: scale(0.97); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes inflate {
  0% { transform: scale(0.82); }
  55% { transform: scale(1.08); }
  74% { transform: scale(0.98) rotate(-0.6deg); }
  90% { transform: scale(1.02) rotate(0.4deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) rotate(-2deg) translateY(0); }
  50% { transform: translateX(-50%) rotate(-2deg) translateY(-6px); }
}

@keyframes wobble {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ============================================================
   Desktop / tablet dressing. The phone column IS the app — on
   bigger screens it floats as a phone-shaped sticker over a
   sunburst sheet. Nothing in here touches viewports < 768px.
   ============================================================ */

@media (min-width: 768px) {
  body {
    background:
      repeating-conic-gradient(from 0deg at 50% 42%, #FFEBC9 0deg 8deg, var(--bg) 8deg 16deg);
  }

  .app {
    background: var(--bg);
    margin: 28px auto;
    height: calc(100dvh - 56px);
    min-height: calc(100dvh - 56px); /* beat the base min-height: 100dvh */
    overflow-y: auto;
    scrollbar-width: none;
    border: var(--border);
    border-radius: 36px;
    box-shadow: 10px 10px 0 var(--ink);
  }

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

  /* tab bar docks onto the frame's bottom edge */
  .tabbar {
    bottom: 28px;
    border: var(--border);
    border-radius: 0 0 33px 33px;
  }

  .toast { bottom: calc(var(--tabbar-h) + 44px); }
}

/* mouse users get a little lift; touch devices never match this */
@media (hover: hover) {
  .card, .vote-btn { transition: transform 0.15s var(--spring), box-shadow 0.15s var(--spring); }

  .btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
  .btn:active { transform: translate(3px, 3px) scale(0.93); box-shadow: 1px 1px 0 var(--ink); }

  .card:hover, .chip:hover, .vote-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 5px 5px 0 var(--ink);
  }

  .tab:hover { opacity: 0.85; }
  .tab.active:hover, .tab.fatten:hover { opacity: 1; }
  .tab.fatten:hover .bubble { transform: scale(1.08); }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
