/* Photos, GIFs, emoji, Paint and the composer's picture tray ------------------ */

/* Photo collages in posts */
.photo-grid { display: grid; gap: 4px; max-width: 520px; border-radius: 16px; overflow: hidden; box-shadow: 0 6px 18px -8px rgba(0, 25, 60, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.4); }
.photo-grid.n-1 { max-height: 560px; }
.photo-grid.n-2 { grid-template-columns: 1fr 1fr; aspect-ratio: 2 / 1.1; }
.photo-grid.n-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 3 / 2; }
.photo-grid.n-3 .photo-cell:first-child { grid-row: span 2; }
.photo-grid.n-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 1; }
.photo-cell { position: relative; padding: 0; border: 0; margin: 0; background: rgba(255, 255, 255, 0.25); cursor: zoom-in; min-height: 0; overflow: hidden; }
.photo-cell img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s var(--ease); }
.photo-cell:hover img { transform: scale(1.03); }
.reply-bubble .photo-grid { max-width: 260px; }

.gif-view { position: relative; margin: 0; max-width: 100%; border-radius: 14px; overflow: hidden; background: rgba(255, 255, 255, 0.2); box-shadow: 0 6px 16px -8px rgba(0, 25, 60, 0.45); }
.gif-view img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gif-view.sticker { background: none; box-shadow: none; border-radius: 0; }
.gif-view.sticker img { object-fit: contain; }
.gif-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  font: 800 0.66rem/1.5 var(--font);
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

/* Short posts on colourful cards */
.post-text.bg-card {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 28px 22px;
  border-radius: 18px;
  text-align: center;
  font-size: clamp(1.25rem, 3.4vw, 1.7rem);
  font-weight: 800;
  line-height: 1.3;
  color: #0b2540;
  text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -20px 40px -20px rgba(0, 0, 0, 0.2), 0 8px 20px -10px rgba(0, 25, 60, 0.5);
  overflow-wrap: anywhere;
}
.post-text.bg-card.ink-light { color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }

/* Composer */
.composer-main { min-width: 0; }
.composer-tools { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.composer-tools::-webkit-scrollbar { display: none; }
.composer-tools .tool { flex: none; }
.composer-actions { align-items: center; flex-wrap: nowrap !important; }
.composer-actions .composer-tools { flex: 1 1 auto; }
.composer-count { flex: none; min-width: 0; }
.composer-count:empty { display: none; }
.post-btn { flex: none; }
.composer.drop-over { outline: 3px dashed rgba(var(--accent-rgb), 0.7); outline-offset: 4px; }

textarea.composer-text.bg-preview {
  min-height: 170px;
  padding: 26px 18px;
  border-radius: 18px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: #0b2540;
  border: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 6px 16px -8px rgba(0, 25, 60, 0.5);
}
textarea.composer-text.bg-preview.ink-light { color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
textarea.composer-text.bg-preview::placeholder { color: inherit; opacity: 0.7; }

.bg-row { display: flex; gap: 8px; flex-wrap: wrap; }
.bg-row[hidden] { display: none; }
.bg-swatch {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7), 0 2px 6px rgba(0, 25, 60, 0.3);
  transition: transform 0.25s var(--spring);
}
.bg-swatch:hover { transform: scale(1.1); }
.bg-swatch.on { box-shadow: 0 0 0 3px var(--accent), inset 0 0 0 2px #fff; }
.bg-swatch.none { display: grid; place-items: center; background: rgba(255, 255, 255, 0.6); color: #0b2540; }

.attach-photos { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); flex: 1 1 100%; }
.attach-photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: visible; }
.attach-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; display: block; box-shadow: 0 3px 10px -4px rgba(0, 25, 60, 0.5); }
.attach-photo.uploading img { opacity: 0.55; }
.attach-spinner { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.attach-gif .gif-view { max-width: 180px; }

/* Emoji picker */
.emoji-picker { display: flex; flex-direction: column; gap: 6px; }
.emoji-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.emoji-tab { flex: none; width: 34px; height: 32px; border: 0; border-radius: 10px; background: none; font-size: 1.15rem; cursor: pointer; }
.emoji-tab.on { background: rgba(var(--accent-rgb), 0.22); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.5); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.emoji-label { grid-column: 1 / -1; padding: 2px 4px 4px; }
.emoji-btn { height: 38px; border: 0; border-radius: 10px; background: none; font-size: 1.45rem; line-height: 1; cursor: pointer; transition: transform 0.2s var(--spring); font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.emoji-btn:hover { transform: scale(1.25); background: rgba(255, 255, 255, 0.35); }

/* GIF picker */
.gif-modal .modal { width: min(640px, 100%); }
.gif-search-wrap { display: flex; align-items: center; gap: 6px; padding-left: 12px; border-radius: 999px; background: var(--field); box-shadow: inset 0 0 0 1px var(--field-line); }
.gif-search-wrap .field { border: 0; background: none; box-shadow: none; padding-left: 0; }
.gif-chips { gap: 6px; }
.gif-chips .chip { font-size: 0.8rem; padding: 3px 10px; }
.gif-scroll { height: min(52vh, 460px); overflow-y: auto; overscroll-behavior: contain; border-radius: 14px; }
.gif-grid { columns: 3 140px; column-gap: 6px; }
.gif-cell { display: block; width: 100%; margin: 0 0 6px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: pointer; background: rgba(var(--accent-rgb), 0.12); break-inside: avoid; transition: transform 0.25s var(--spring); }
.gif-cell.sticker { background: rgba(255, 255, 255, 0.25); }
.gif-cell:hover { transform: scale(1.03); }
.gif-cell img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gif-cell.sticker img { object-fit: contain; }
.gif-more { height: 1px; }
.gif-off { padding: 40px 16px; }
.gif-grid > :not(.gif-cell) { column-span: all; }
.gif-type { flex: none; }
.big-emoji { font-size: 2.6rem; }
.giphy-credit { text-align: right; opacity: 0.75; letter-spacing: 0.04em; }

/* Paint */
.paint-modal .modal { width: min(900px, 100%); }
.paint { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr auto; gap: 10px; }
.paint-side { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.paint-tools, .paint-sizes { display: flex; flex-direction: column; gap: 4px; }
.paint-sep { width: 70%; height: 1px; background: var(--hair); margin: 2px 0; }
.paint-tool, .paint-size {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 3px rgba(0, 25, 60, 0.2);
}
.paint-tool.on, .paint-size.on { color: #fff; background: linear-gradient(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 50%), var(--accent); }
.paint-size i { display: block; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.paint-stage { min-width: 0; display: grid; place-items: center; }
.paint-canvas {
  width: 100%;
  max-width: min(560px, 62vh);
  aspect-ratio: 1;
  border-radius: 6px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 10px 26px -10px rgba(0, 25, 60, 0.55);
}
.paint-bottom { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.paint-colors { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.paint-color { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.2); }
.paint-color.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.paint-history { gap: 2px; }
@media (max-width: 640px) {
  .paint { grid-template-columns: 1fr; }
  .paint-side { flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .paint-tools, .paint-sizes { flex-direction: row; }
  .paint-sep { width: 1px; height: 30px; }
  .paint-tool, .paint-size { width: 38px; height: 38px; }
  .paint-canvas { max-width: 100%; }
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(2, 8, 20, 0.88);
  animation: lb-in 0.2s ease;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: pan-y;
}
.lightbox.out { opacity: 0; transition: opacity 0.2s; }
@keyframes lb-in { from { opacity: 0; } }
.lb-stage { width: 100%; height: 100%; display: grid; place-items: center; padding: 56px 12px; }
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); user-select: none; -webkit-user-drag: none; }
.lb-close, .lb-nav {
  position: absolute;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  z-index: 1;
}
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lb-nav { top: 50%; margin-top: -22px; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-nav[hidden] { display: none; }
.lb-count { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, 0.8); }

/* Chat pictures */
.msg-photo { display: block; max-width: min(280px, 70vw); border-radius: 14px; overflow: hidden; cursor: zoom-in; padding: 0; border: 0; background: none; }
.msg-photo img { display: block; width: 100%; height: auto; }
.msg-gif .gif-view { max-width: min(240px, 66vw); }

/* Profile photo cropper */
.crop-modal .modal { width: min(360px, 100%); }
.center-col { align-items: center; }
.crop-stage { position: relative; overflow: hidden; border-radius: 16px; background: #0b1a2e; touch-action: none; cursor: grab; user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-img { position: absolute; left: 50%; top: 50%; max-width: none; pointer-events: none; }
.crop-ring { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle closest-side, transparent calc(100% - 1px), rgba(4, 12, 28, 0.6) 100%); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35); }
.crop-ring::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9); }
.crop-zoom { width: 100%; max-width: 260px; }
.crop-zoom .range { flex: 1; }
