/* Window overlay (PLAN.md 4.2) and the shared media blocks (PLAN.md 7.1). Uses only tokens from theme.css. */
.icon { width: 1.1em; height: 1.1em; vertical-align: -0.18em; flex: none; }

.win-root {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: stretch; justify-content: center;
  background: var(--backdrop); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.5;
  animation: win-fade 150ms var(--ease-out);
}
.win-root *, .win-root *::before, .win-root *::after { box-sizing: border-box; }
.win-root.closing { opacity: 0; transition: opacity 150ms; }
@keyframes win-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .win-root { animation: none; } .win-root.closing { transition: none; } }

.win {
  display: flex; flex-direction: column; width: 100%; background: var(--surface); overflow: hidden;
}
@media (min-width: 600px) {
  .win-root { align-items: center; padding: 16px; }
  .win { max-width: 760px; max-height: 90vh; border-radius: var(--radius); box-shadow: var(--shadow); }
}
.win :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.win-head {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: .9rem;
}
.win-x {
  display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 0; border-radius: var(--radius-s);
  background: none; color: var(--ink); cursor: pointer; font-size: 1.2rem;
}
.win-x:hover { background: var(--line); }
.win-preview { background: #ffe9a8; color: #4a3a00; padding: 6px 18px; font-size: .85rem; font-weight: 600; text-align: center; }
.win-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.win-title {
  margin: 0; padding: 16px 18px 4px; font: 600 clamp(1.3rem, 4vw, 1.8rem)/1.2 Fraunces, Georgia, "Times New Roman", serif; color: var(--ink);
}
.win-body { padding: 8px 18px 18px; min-height: 120px; }
.win-foot { padding: 4px 18px 22px; text-align: center; }
.win-btn {
  min-height: 44px; padding: 8px 20px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.win-btn:hover { filter: brightness(1.06); }

/* ---- blocks ---- */
.blocks { display: flex; flex-direction: column; gap: 16px; }
.blk { margin: 0; max-width: 100%; }
.blk-text { font-size: 17px; line-height: 1.55; max-width: 65ch; overflow-wrap: anywhere; }
.blk-text p { margin: 0 0 .7em; } .blk-text p:last-child { margin-bottom: 0; }
.blk-text a, .blk-caption a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 2px; }
.blk-caption { margin-top: 6px; color: var(--ink-soft); font-size: .9rem; overflow-wrap: anywhere; }
.blk-img { display: block; width: 100%; height: auto; border-radius: var(--radius-s); background: var(--line); }
.blk-imgbtn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--radius-s); }
.blk-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 600px) { .blk-gallery { grid-template-columns: repeat(3, 1fr); } }
.blk-gallery .blk-imgbtn { aspect-ratio: 1; overflow: hidden; }
.blk-gallery .blk-img { height: 100%; object-fit: cover; }
.blk-video { display: block; width: 100%; max-height: 70vh; border-radius: var(--radius-s); background: #000; }
.blk-audio { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff8; }
.blk-audio-title { margin-bottom: 6px; font-weight: 600; overflow-wrap: anywhere; }
.blk-audio audio { display: block; width: 100%; }
.blk-link {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; width: 100%;
  border: 2px solid var(--ink); border-radius: var(--radius-s); color: var(--ink); text-decoration: none; font-weight: 600; text-align: center; overflow-wrap: anywhere;
}
.blk-link:hover { background: var(--ink); color: var(--surface); }
.blk-embed { position: relative; aspect-ratio: 16 / 9; width: 100%; border-radius: var(--radius-s); overflow: hidden; background: #111; }
.blk-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.blk-embed-play {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%;
  border: 0; background: linear-gradient(135deg, #1d3156, #0f1b2d); color: #f4efe4; font: inherit; cursor: pointer;
}
.blk-embed-play .icon { width: 52px; height: 52px; padding: 12px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.blk-embed-play small { opacity: .8; }
.blk-broken { padding: 10px; border: 1px dashed var(--line); border-radius: var(--radius-s); color: var(--ink-soft); font-size: .9rem; }
.blk-reveal { animation: blk-in 400ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 80ms); }
@keyframes blk-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .blk-reveal { animation: none; } }

/* ---- lightbox (inner layer: Esc closes it before the window) ---- */
.lightbox { position: fixed; inset: 0; z-index: 1100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; background: rgb(0 0 0 / .9); color: #fff; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; }
.lightbox-bar { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.lightbox button { min-width: 44px; min-height: 44px; border: 0; border-radius: 999px; background: rgb(255 255 255 / .16); color: #fff; font: inherit; cursor: pointer; }
.lightbox button:hover { background: rgb(255 255 255 / .3); }
.lightbox-x { position: absolute; top: 8px; right: 8px; }
.lightbox-cap { max-width: 70ch; text-align: center; font-size: .9rem; }

/* ---- confetti ---- */
.confetti { position: fixed; z-index: 1200; width: 6px; height: 10px; pointer-events: none; animation: confetti 1.2s ease-out forwards; }
@keyframes confetti { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
