/* Tight Ship: the real-screen viewer. assets/js/screen.js makes the markup (a <dialog class="sv">) and sets
   the window's size through the CSSOM on desktop; this file does the rest. Everything here sits under .sv,
   or is the one class screen.js puts on <html> while the window is open (sv-lock), so it never restyles a page.
   Desktop: the window floats on a dimmed page, up to 1200 px wide, never taller than the screen.
   Phone (under 640 px wide, or under 500 px tall): the window fills the screen and scrolls; pinch zoom works.
   Motion: a short fade and rise in (0.22 s, the brand's ease-out), a shorter fade out. None with reduced motion. */

html.sv-lock { overflow: hidden; scrollbar-gutter: stable; }

.sv {
  --sv-ground: #fffdf8;              /* the window: the price card's lighter paper (product.css, --pp-card) */
  --sv-hair: rgba(12, 22, 37, .12);
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 24px; border: 0; background: transparent; color: var(--ink);
  overflow: hidden; overscroll-behavior: contain;
  font: 400 var(--fs-body)/1.6 var(--text);
}
.sv[open] { display: grid; place-items: center; }
.sv::backdrop { background: rgba(12, 22, 37, .62); }
.sv *, .sv *::before, .sv *::after { box-sizing: border-box; }
.sv [hidden] { display: none !important; }
.sv :focus-visible { outline: 3px solid var(--orange-text); outline-offset: 2px; border-radius: 8px; }

.sv-win {
  display: flex; flex-direction: column; width: min(880px, 100%); max-width: 100%; max-height: 100%; min-width: 0;
  background: var(--sv-ground); border-radius: 14px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(12, 22, 37, .2), 0 32px 80px -24px rgba(12, 22, 37, .6);
}

/* the title bar: the name and the Sample data tag, then Full size and Close */
.sv-bar {
  flex: none; display: flex; align-items: center; gap: 8px;
  min-height: 64px; padding: 10px 10px 10px 22px;
  background: var(--sv-ground); border-bottom: 1px solid var(--sv-hair);
}
.sv-head { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.sv-t {
  margin: 0; min-width: 0; font: 400 21px/1.25 var(--serif); letter-spacing: -.005em;
  color: var(--ink); overflow-wrap: anywhere; text-wrap: balance;
}
.sv-tag {
  margin: 0; flex: none; padding: 1px 10px; border: 1px solid rgba(12, 22, 37, .28); border-radius: 999px;
  color: var(--steel); font: 600 14px/1.5 var(--text); white-space: nowrap;
}
.sv-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; min-width: 44px; padding: 0 14px; margin: 0;
  border: 2px solid rgba(12, 22, 37, .2); border-radius: 10px; background: transparent; color: var(--ink);
  font: 600 16px/1 var(--text); cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, transform .12s ease;
}
.sv-btn:hover { background: rgba(12, 22, 37, .06); border-color: rgba(12, 22, 37, .32); }
.sv-btn:active { transform: translateY(1px); }
.sv-x { border-color: var(--green); color: var(--green); }
.sv-x:hover { background: var(--green); border-color: var(--green); color: var(--sv-ground); }
.sv-ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.sv-ic--fit, .sv.is-full .sv-ic--grow { display: none; }
.sv.is-full .sv-ic--fit { display: block; }

/* the capture, on bone, untouched: only scaled */
.sv-view {
  position: relative; flex: none; display: grid; place-items: center; min-height: 0;
  padding: 16px; background: var(--bone); overscroll-behavior: contain;
}
.sv-img {
  display: block; max-width: none; background: #fff; border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(12, 22, 37, .12), 0 10px 26px -14px rgba(12, 22, 37, .45);
  transition: opacity .2s cubic-bezier(0.33, 1, 0.68, 1);
  -webkit-user-select: none; user-select: none;
}
.sv.can-zoom .sv-img { cursor: zoom-in; }
.sv.is-full .sv-view { display: block; overflow: auto; }
.sv.is-full .sv-img { margin-inline: auto; cursor: zoom-out; }
.sv.is-drag .sv-img { cursor: grabbing; }
.sv.is-full .sv-view:focus-visible { outline-offset: -3px; border-radius: 0; }

/* still loading: a quiet ring where the picture will be */
.sv.is-loading .sv-img { opacity: 0; }
.sv.is-loading .sv-view::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border: 3px solid rgba(12, 22, 37, .14); border-top-color: var(--orange); border-radius: 50%;
}

.sv-n {
  flex: none; margin: 0; padding: 12px 22px 14px; border-top: 1px solid var(--sv-hair);
  color: var(--steel); font-size: 16px; line-height: 1.5;
}

/* motion */
@media (prefers-reduced-motion: no-preference) {
  .sv[open] .sv-win { animation: sv-in .22s cubic-bezier(0.33, 1, 0.68, 1) both; }
  .sv[open]::backdrop { animation: sv-fade .22s cubic-bezier(0.33, 1, 0.68, 1) both; }
  .sv.is-closing .sv-win { animation: sv-out .16s cubic-bezier(0.32, 0, 0.67, 0) both; }
  .sv.is-closing::backdrop { animation: sv-fade-out .16s cubic-bezier(0.32, 0, 0.67, 0) both; }
  .sv.is-loading .sv-view::after { animation: sv-spin .8s linear infinite; }
}
@keyframes sv-in { from { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes sv-out { to { opacity: 0; transform: translateY(6px) scale(.99); } }
@keyframes sv-fade { from { opacity: 0; } }
@keyframes sv-fade-out { to { opacity: 0; } }
@keyframes sv-spin { to { transform: rotate(360deg); } }

/* phone: the window is the whole screen. The bar stays at the top, the capture fits the width
   (pinch to zoom), and the note sits under it. Full size shows only for a wide sheet (screen.js decides):
   it switches to the readable size that scrolls sideways, and Fit to window fits it again. */
@media (max-width: 639px), (max-height: 499px) {
  .sv { padding: 0; height: 100dvh; }
  .sv[open] { display: block; }
  .sv-win {
    width: 100%; height: 100%; max-height: none; border-radius: 0; box-shadow: none;
    overflow-y: auto; overscroll-behavior: contain;
  }
  .sv-bar { position: sticky; top: 0; z-index: 1; min-height: 60px; padding: 8px 8px 8px 16px; align-items: center; }
  .sv-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .sv-t { font-size: 19px; }
  .sv-btn { padding: 0 10px; }
  .sv-view { flex: 1 0 auto; padding: 10px; }
  .sv-img { width: 100%; height: auto; }
  .sv-n { padding: 12px 16px 18px; }
  /* a wide sheet: shown at a readable size, scrolling sideways (screen.js sets its size). It starts at its
     left edge (start, not center: a centered sheet wider than the screen would hide its left part) and sits
     in the middle of the space top to bottom. */
  .sv.is-wide .sv-view { display: grid; place-items: center start; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sv.is-wide .sv-img { max-width: none; }
}
