/* Mel's movie — "Add to Mel's movie" sheet + preview player (stream S7).
   Everything is scoped under .reel-sheet / .reel-movie / .reel-ghost. */

.reel-sheet, .reel-movie, .reel-ghost {
  --reel-sea: #08323b;
  --reel-sea-2: #0d4f5a;
  --reel-deep: #041c22;
  --reel-sun: #ffcf3f;
  --reel-sun-2: #f2b53a;
  --reel-sun-3: #b9751c;
  --reel-pink: #ff4f8b;
  --reel-pink-2: #ff8fb4;
  --reel-lagoon: #1fb5a8;
  --reel-cream: #fff6e6;
  --reel-ink: #102127;
  --reel-display: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --reel-hand: "Caveat", "Bradley Hand", cursive;
  --reel-thumb-h: 112px;
  font-family: var(--reel-display);
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}
.reel-sheet *, .reel-movie *, .reel-ghost * { box-sizing: border-box; }
html.reel-open, html.reel-open body { overflow: hidden; }

/* ---------- sheet ---------- */
.reel-sheet {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  color: var(--reel-cream);
  background: radial-gradient(120% 90% at 50% 0%, var(--reel-sea-2), var(--reel-sea) 60%, var(--reel-deep));
  transform: translateY(24px); opacity: 0;
  transition: transform .26s cubic-bezier(.2, 1.1, .4, 1), opacity .2s ease;
}
.reel-sheet.reel-in { transform: none; opacity: 1; }
.reel-sheet button { font: inherit; cursor: pointer; color: inherit; }

.reel-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.reel-sheet [hidden], .reel-movie [hidden] { display: none !important; }
.reel-sheet:focus { outline: none; }
.reel-titles { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 14px; }
.reel-head h1 {
  margin: 0; min-width: 0;
  font-size: clamp(22px, 6vw, 32px); font-weight: 800; letter-spacing: -.02em; line-height: 1.05;
  color: var(--reel-sun);
}
.reel-clap { display: inline-block; transform: rotate(-8deg); }
.reel-status {
  font-family: var(--reel-hand); font-size: 20px; line-height: 1; white-space: nowrap;
  color: rgba(255, 246, 230, .75);
}
.reel-status.busy::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--reel-sun); animation: reel-pulse 1s ease-in-out infinite; vertical-align: 2px; }
.reel-status.wait { color: var(--reel-pink-2); }
.reel-status.ok { color: var(--reel-lagoon); }
.reel-x {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .12); font-size: 20px;
}

.reel-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 24px; -webkit-overflow-scrolling: touch; }
.reel-add, .reel-film { max-width: 880px; margin: 0 auto; }
.reel-intro { margin: 0 0 12px; font-size: 16px; line-height: 1.35; color: rgba(255, 246, 230, .85); }

/* big add button */
.reel-big {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 76px; padding: 12px 22px; border: 0; border-radius: 26px;
  text-align: left; color: var(--reel-ink) !important;
  background: linear-gradient(180deg, #fff1b0, var(--reel-sun) 45%, var(--reel-sun-2));
  box-shadow: 0 7px 0 var(--reel-sun-3), 0 16px 30px rgba(0, 0, 0, .35);
  transition: transform .12s, box-shadow .12s;
}
.reel-big:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--reel-sun-3), 0 8px 18px rgba(0, 0, 0, .35); }
.reel-big:focus-visible, .reel-chip:focus-visible, .reel-thumb:focus-visible, .reel-sheet button:focus-visible { outline: 3px solid var(--reel-pink); outline-offset: 3px; }
.reel-big-plus {
  flex: none; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--reel-pink); color: #fff; font-size: 34px; font-weight: 800; line-height: 1;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.reel-big-text { display: flex; flex-direction: column; }
.reel-big-text b { font-size: clamp(20px, 5.4vw, 24px); font-weight: 800; letter-spacing: -.01em; }
.reel-big-text small { font-size: 15px; font-weight: 500; opacity: .75; }
.reel-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.reel-note {
  /* a toast just above the footer, so it's seen wherever you've scrolled to */
  position: absolute; z-index: 4; left: 50%; translate: -50% 0;
  bottom: calc(88px + env(safe-area-inset-bottom)); width: max-content; max-width: min(92vw, 520px);
  margin: 0; padding: 12px 18px; border-radius: 18px;
  background: var(--reel-cream); color: var(--reel-ink);
  font-size: 16px; line-height: 1.3; font-weight: 500;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
.reel-note.reel-pop { animation: reel-pop .35s cubic-bezier(.2, 1.6, .4, 1); }

/* chapter chips */
.reel-label { margin: 20px 0 8px; font-family: var(--reel-hand); font-size: 26px; line-height: 1; color: var(--reel-pink-2); }
.reel-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.reel-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 14px 8px 10px; border-radius: 999px;
  border: 2px solid rgba(255, 246, 230, .22); background: rgba(255, 255, 255, .07);
  font-size: 16px; font-weight: 600; line-height: 1.1;
  transition: background .15s, border-color .15s, transform .12s;
}
.reel-chip:active { transform: scale(.96); }
.reel-chip.on { background: var(--reel-pink); border-color: var(--reel-pink); color: #fff; box-shadow: 0 4px 0 #b8255a; }
.reel-chip-emoji { font-size: 20px; line-height: 1; }

/* selected entry card */
.reel-card {
  display: flex; gap: 14px; margin-top: 18px; padding: 12px;
  border-radius: 22px; background: var(--reel-cream); color: var(--reel-ink);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
  animation: reel-pop .3s cubic-bezier(.2, 1.4, .4, 1);
}
.reel-card-media {
  position: relative; flex: none; width: 112px; align-self: flex-start;
  background: #fffdf8; padding: 6px 6px 22px; border-radius: 3px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .25); transform: rotate(-3deg);
}
.reel-card-media img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.reel-card-play { display: grid; place-items: center; aspect-ratio: 1; background: var(--reel-sea); font-size: 34px; }
.reel-card-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.reel-card-who { margin: 0; font-family: var(--reel-hand); font-size: 24px; line-height: 1; color: var(--reel-pink); }
.reel-saving { font-size: 18px; color: rgba(16, 33, 39, .55); }
.reel-card-cap { margin: 0; font-family: var(--reel-hand); font-size: 22px; line-height: 1.1; }
.reel-card-hint { margin: 0; font-size: 14px; color: rgba(16, 33, 39, .7); }
.reel-caption {
  width: 100%; resize: none; border: 2px solid rgba(16, 33, 39, .15); border-radius: 14px;
  padding: 8px 12px; background: #fff; color: var(--reel-ink);
  font: 600 22px/1.15 var(--reel-hand);
}
.reel-caption:focus { outline: none; border-color: var(--reel-lagoon); box-shadow: 0 0 0 3px rgba(31, 181, 168, .25); }
.reel-caption::placeholder { color: rgba(16, 33, 39, .45); }
.reel-card { flex-wrap: wrap; row-gap: 10px; }
.reel-card-row { flex-basis: 100%; display: flex; align-items: center; gap: 8px; }
.reel-move { justify-content: space-between; max-width: 520px; }
.reel-move .reel-nudge { flex: 1; max-width: 170px; }
.reel-nudge, .reel-remove, .reel-ghost-btn {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 0;
  font-size: 15px; font-weight: 700;
}
.reel-sheet .reel-nudge { background: var(--reel-sea-2); color: var(--reel-cream); }
.reel-nudge:disabled { opacity: .35; cursor: default; }
.reel-pos { font-size: 14px; color: rgba(16, 33, 39, .6); min-width: 52px; text-align: center; }
.reel-sheet .reel-remove { background: rgba(255, 79, 139, .12); color: #c22a62; }
.reel-sheet .reel-remove[data-armed] { background: var(--reel-pink); color: #fff; }
.reel-sheet .reel-ghost-btn { background: rgba(31, 181, 168, .16); color: #0b6d64; margin-left: auto; }

/* filmstrips */
.reel-film { margin-top: 26px; }
.reel-film-title { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--reel-sun); }
.reel-film-title small { font-family: var(--reel-hand); font-weight: 600; font-size: 22px; color: var(--reel-pink-2); margin-left: 4px; }
.reel-chapter { margin-top: 14px; }
.reel-chapter h3 { display: flex; align-items: baseline; gap: 6px; margin: 0 0 6px; font-size: 17px; font-weight: 800; }
.reel-chapter h3 small { font-family: var(--reel-hand); font-weight: 600; font-size: 19px; color: var(--reel-pink-2); }
.reel-count { margin-left: auto; font-size: 14px; font-weight: 600; opacity: .6; }
.reel-strip {
  position: relative; display: flex; gap: 10px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
  padding: 10px 12px 12px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  background:
    radial-gradient(circle at 8px 5px, rgba(0,0,0,.45) 3px, transparent 3.5px) 0 0 / 18px 10px repeat-x,
    radial-gradient(circle at 8px 5px, rgba(0,0,0,.45) 3px, transparent 3.5px) 0 100% / 18px 10px repeat-x,
    rgba(0, 0, 0, .28);
  scroll-snap-type: x proximity;
}
.reel-strip-end { flex: none; display: flex; align-items: center; min-height: calc(var(--reel-thumb-h) + 24px); padding-right: 8px; }
.reel-strip-end span { font-family: var(--reel-hand); font-size: 22px; color: rgba(255, 246, 230, .6); white-space: nowrap; }

.reel-thumb {
  flex: none; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: calc(var(--reel-thumb-h) * .82); user-select: none; -webkit-user-select: none;
  scroll-snap-align: center; cursor: pointer; outline: none;
  -webkit-touch-callout: none;
}
.reel-thumb.own { cursor: grab; }
.reel-thumb-img {
  position: relative; width: 100%; height: var(--reel-thumb-h);
  background: #fffdf8; padding: 4px 4px 18px; border-radius: 3px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, .35);
  transition: transform .15s, box-shadow .15s;
}
.reel-thumb:nth-child(3n+1) .reel-thumb-img { transform: rotate(-1.5deg); }
.reel-thumb:nth-child(3n+2) .reel-thumb-img { transform: rotate(1.2deg); }
.reel-thumb-img img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.reel-thumb-blank { display: grid; place-items: center; height: 100%; background: var(--reel-sea); font-size: 30px; }
.reel-thumb.own .reel-thumb-img { box-shadow: 0 0 0 3px var(--reel-pink), 0 6px 12px rgba(0, 0, 0, .35); }
.reel-thumb.sel .reel-thumb-img {
  box-shadow: 0 0 0 4px var(--reel-sun), 0 0 22px 4px rgba(255, 207, 63, .55);
  transform: translateY(-3px) rotate(0) scale(1.04);
}
.reel-thumb.sel .reel-thumb-img { animation: reel-glow 1.6s ease-in-out infinite; }
.reel-thumb.pending img { opacity: .8; }
.reel-by {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--reel-hand); font-size: 19px; line-height: 1; color: var(--reel-cream);
}
.reel-thumb.own .reel-by { color: var(--reel-pink-2); font-weight: 700; }
.reel-badge-play {
  position: absolute; left: 50%; top: calc(50% - 7px); translate: -50% -50%;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; padding-left: 2px;
}
.reel-dot { position: absolute; right: 6px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--reel-sun); border: 2px solid #fff; animation: reel-pulse 1s ease-in-out infinite; }
.reel-thumb.reel-wobble .reel-thumb-img { animation: reel-wobble .5s ease; }

/* drag */
.reel-slot {
  flex: none; height: calc(var(--reel-thumb-h) + 20px); border-radius: 10px;
  border: 3px dashed var(--reel-sun); background: rgba(255, 207, 63, .12);
}
.reel-ghost {
  position: fixed; left: 0; top: 0; z-index: 1100; pointer-events: none; margin: 0;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .5));
}
.reel-ghost .reel-by { color: var(--reel-pink-2); }
.reel-dragging, .reel-dragging * { cursor: grabbing !important; }

/* footer */
.reel-foot {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(4, 28, 34, .85) 30%);
}
.reel-play {
  flex: 1; max-width: 420px; min-height: 54px; border: 0; border-radius: 999px;
  font-size: 19px; font-weight: 800; color: #fff !important;
  background: linear-gradient(180deg, #ff7aa8, var(--reel-pink));
  box-shadow: 0 6px 0 #b8255a, 0 12px 24px rgba(0, 0, 0, .35);
}
.reel-play:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8255a; }
.reel-done { min-height: 54px; padding: 0 22px; border: 0; border-radius: 999px; font-size: 18px; font-weight: 700; background: rgba(255, 255, 255, .14); }

/* desktop drop target */
.reel-dropzone {
  position: absolute; inset: 10px; z-index: 5; display: none; place-items: center;
  border: 4px dashed var(--reel-sun); border-radius: 28px; background: rgba(8, 50, 59, .85);
  pointer-events: none;
}
.reel-dropzone div { font-size: 30px; font-weight: 800; color: var(--reel-sun); }
.reel-sheet.reel-dropping .reel-dropzone { display: grid; }

@media (min-width: 760px) {
  .reel-sheet { --reel-thumb-h: 132px; }
  .reel-scroll { padding: 8px 32px 32px; }
  .reel-head { padding-left: 32px; padding-right: 32px; }
  .reel-strip { margin: 0; border-radius: 14px; }
  .reel-card-media { width: 150px; }
}

/* ---------- movie preview ---------- */
.reel-movie { position: fixed; inset: 0; z-index: 1200; background: #000; color: #fff; overflow: hidden; }
.reel-movie button { font: inherit; cursor: pointer; }
.reel-movie-slide { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity 1s ease; overflow: hidden; }
.reel-movie-slide.show { opacity: 1; }
.reel-movie-bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) brightness(.55) saturate(1.3); transform: scale(1.1); }
.reel-polaroid {
  position: relative; margin: 0; background: #fffdf8; padding: 12px 12px 0; border-radius: 3px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .55); max-width: min(86vw, 640px);
  rotate: var(--r);
}
.reel-polaroid img, .reel-polaroid video {
  display: block; max-width: 100%; width: auto; height: auto;
  max-height: min(60vh, 620px); max-height: min(58dvh, 620px); background: #111;
}
.reel-polaroid figcaption {
  min-height: 54px; padding: 8px 4px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px;
  color: var(--reel-ink); text-align: center;
}
.reel-cap-text { font: 700 clamp(22px, 5.6vw, 28px)/1.05 var(--reel-hand); max-width: 30ch; }
.reel-cap-by {
  display: inline-block; padding: 3px 10px 4px; border-radius: 999px;
  background: var(--reel-pink); color: #fff; font: 700 17px/1 var(--reel-hand); transform: rotate(-2deg);
}
.reel-polaroid.reel-yours { outline: 4px solid var(--reel-sun); outline-offset: 6px; }
.reel-movie-slide.show .reel-polaroid { animation: reel-drop 1.1s cubic-bezier(.2, 1.3, .4, 1) both, reel-drift 4s ease-out both; }
.reel-movie-chapter { text-align: center; padding: 16px; position: relative; }
.reel-movie-chapter small { display: block; font-family: var(--reel-hand); color: var(--reel-pink-2); font-size: clamp(26px, 6vw, 40px); }
.reel-movie-chapter h2 { margin: 6px 0 0; font-size: clamp(40px, 11vw, 96px); font-weight: 800; line-height: .95; letter-spacing: -.03em; color: var(--reel-sun); }
.reel-movie-slide.show .reel-movie-chapter h2 { animation: reel-stamp .8s cubic-bezier(.2, 1.6, .4, 1) both; }
.reel-movie-ui {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.reel-movie-ui button {
  background: rgba(255, 255, 255, .14); border: 0; color: #fff; border-radius: 999px;
  min-width: 44px; height: 44px; padding: 0 14px; font-size: 16px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.reel-movie-bar { flex: 1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.reel-movie-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--reel-pink), var(--reel-sun)); transition: width .4s linear; }
.reel-sound {
  position: absolute; z-index: 6; top: calc(14px + env(safe-area-inset-top)); left: 50%; translate: -50% 0;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--reel-sun); color: var(--reel-ink); font-weight: 800; font-size: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4); animation: reel-pop .4s cubic-bezier(.2, 1.6, .4, 1);
}

/* ---------- motion ---------- */
@keyframes reel-pulse { 50% { opacity: .35; transform: scale(.8); } }
@keyframes reel-pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes reel-glow { 50% { box-shadow: 0 0 0 4px var(--reel-sun), 0 0 30px 10px rgba(255, 207, 63, .75); } }
@keyframes reel-wobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-6deg); } 40% { transform: rotate(5deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }
@keyframes reel-drop { from { transform: translateY(-40px) rotate(calc(var(--r0) - var(--r))) scale(1.15); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes reel-drift { to { translate: var(--dx) 0; } }
@keyframes reel-stamp { from { transform: scale(2.2) rotate(-6deg); opacity: 0; } to { transform: scale(1) rotate(-2deg); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .reel-sheet, .reel-sheet *, .reel-movie *, .reel-ghost { animation: none !important; transition: none !important; }
  .reel-movie-slide.show .reel-movie-chapter h2 { transform: rotate(-2deg); }
}
