/* Production Portal (features/portal.js): one white page per production, side by side, all the same width;
   the production's icon and name above each. The row scrolls sideways; each page scrolls down. */

body.page-portal { background: var(--bg-home); }
body.page-portal .app-footer { display: none; }
body.page-portal .app-header { background: light-dark(rgba(251, 251, 253, 0.85), rgba(28, 28, 30, 0.85)); border-bottom-color: var(--border); }
main.app-main.portal-main { position: relative; padding: 0; display: flex; flex-direction: column; height: calc(100dvh - var(--bar-h) - var(--safe-top)); min-height: 380px; }
.portal-main [hidden] { display: none !important; }

/* ---- search, above the first production ---- */
.portal-bar { flex: none; display: flex; align-items: center; padding: 18px max(var(--page-gutter), var(--safe-right)) 0 max(var(--page-gutter), var(--safe-left)); }
.portal-search { flex: none; display: flex; align-items: center; gap: 8px; width: 300px; max-width: 100%; height: 38px; padding: 0 12px;
  border-radius: 10px; background: var(--card); border: 1px solid var(--border-strong); color: var(--text-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03); transition: border-color .15s, box-shadow .15s; }
.portal-search:focus-within { border-color: rgba(0, 113, 227, 0.4); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1); }
.portal-search svg { width: 16px; height: 16px; flex: none; }
.portal-search-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font: inherit; font-size: 14px; color: var(--text); }
.portal-search-input:focus-visible { outline: none; }
.portal-search-input::placeholder { color: var(--text-3); }
.portal-search-input::-webkit-search-cancel-button { cursor: pointer; }
@media (max-width: 640px) { .portal-bar { padding: 12px 12px 0; } .portal-search { width: 100%; } }

/* ---- the row of productions ---- */
.portal-row { flex: 1; min-height: 0; display: flex; gap: 20px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  padding: 16px max(var(--page-gutter), var(--safe-right)) max(20px, var(--safe-bottom)) max(var(--page-gutter), var(--safe-left));
  scroll-padding-inline: var(--page-gutter); scrollbar-width: thin; scrollbar-color: light-dark(rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.24)) transparent; }
.portal-status { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; pointer-events: none; }
.portal-status > * { pointer-events: auto; }

.pf { --pf-w: clamp(300px, 27vw, 420px); flex: 0 0 var(--pf-w); width: var(--pf-w); min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.pf-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 0 4px; min-width: 0; }
.pf-mark { flex: none; width: 30px; height: 30px; border-radius: 8px; overflow: hidden; background: var(--pill-bg); display: grid; place-items: center; }
.pf-mark img { width: 100%; height: 100%; object-fit: cover; }
.pf-mark .initials { font-size: 11px; font-weight: 650; color: var(--text-2); }
.pf-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); }
.pf-name:hover { color: var(--blue); }

.pf-page { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; overscroll-behavior: contain; cursor: text;
  background: var(--card); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 6px 20px -12px rgba(0, 0, 0, 0.12);
  transition: border-color .15s, box-shadow .15s; scrollbar-width: thin; scrollbar-color: light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.24)) transparent; }
.pf-page:focus-within { border-color: rgba(0, 113, 227, 0.35); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.08), 0 6px 20px -12px rgba(0, 0, 0, 0.12); }
.pf.loading .pf-page { background: linear-gradient(90deg, var(--card), light-dark(#f7f7f9, #212124), var(--card)); background-size: 200% 100%; animation: pf-shimmer 1.4s linear infinite; }
@keyframes pf-shimmer { to { background-position: -200% 0; } }

/* the sheet: the text and, over it, the drawing layer (both scroll with the page) */
.pf-sheet { position: relative; flex: 1 0 auto; display: flex; flex-direction: column; }
.pf-ink { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 1; }
.pf-ink path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.portal-main[data-tool="pen"] .pf-ink, .portal-main[data-tool="eraser"] .pf-ink { pointer-events: auto; touch-action: none; }
.portal-main[data-tool="pen"] .pf-ink { cursor: crosshair; }
.portal-main[data-tool="eraser"] .pf-ink { cursor: cell; }

/* the document */
.pf-doc { --pad-y: 22px; --pad-x: 24px; position: relative; flex: 1 0 auto; padding: var(--pad-y) var(--pad-x) 48px; outline: none; font-size: 15px; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; cursor: text; }
/* the hint takes no room (absolute, at its static spot), so the caret starts at the left, under it */
.pf-doc.is-blank::before { content: attr(data-placeholder); position: absolute; top: var(--pad-y); left: var(--pad-x); color: var(--text-3); pointer-events: none; }
.pf-doc > :first-child { margin-top: 0; }
.pf-doc p, .pf-doc div { margin: 0; }
.pf-doc h1, .pf-doc h2, .pf-doc h3 { margin: .6em 0 .25em; line-height: 1.25; letter-spacing: -0.015em; }
.pf-doc ul, .pf-doc ol { margin: .25em 0; padding-left: 1.4em; }
.pf-doc li { margin: .1em 0; }
.pf-doc li::marker { color: var(--text-2); }
.pf-doc blockquote { margin: .4em 0; padding-left: 12px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.pf-doc ::selection { background: rgba(0, 113, 227, 0.18); }
@media (prefers-reduced-motion: reduce) { .pf.loading .pf-page { animation: none; } }

/* someone else saved meanwhile / not saved: one quiet line above the page */
.pf-note { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 7px 12px; border-radius: 10px; font-size: 12.5px; }
.pf-note[data-kind="error"] { background: var(--amber-50); border: 1px solid var(--amber-200); color: var(--amber-700); }
.pf-note[data-kind="conflict"] { background: var(--blue-soft); border: 1px solid var(--blue-200); color: light-dark(#0b5cb8, #6cadf6); }
.pf-note span { flex: 1; min-width: 0; }
.pf-note-btn { padding: 3px 10px; border-radius: 999px; background: var(--card); border: 1px solid currentColor; font-size: 12px; font-weight: 600; }
.pf-note-btn:hover { background: light-dark(rgba(255, 255, 255, 0.6), rgba(28, 28, 30, 0.6)); }

/* ---- the toolbar, beside the search ---- */
/* three columns — search · toolbar · (balance) — so the toolbar sits exactly in the middle of the portal */
.portal-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; }
.portal-bar > .portal-search { justify-self: start; }
@media (max-width: 1000px) { .portal-bar { grid-template-columns: minmax(0, 1fr); } .portal-bar > .portal-tools { justify-self: start; } }
.portal-tools { display: flex; align-items: center; gap: 2px; padding: 3px; min-height: 38px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03); }
.pt-group { display: flex; align-items: center; gap: 2px; }
.pt-btn { min-width: 30px; height: 30px; padding: 0 7px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  color: var(--text-2); font-size: 14px; line-height: 1; transition: background .12s, color .12s; }
.pt-btn svg { width: 16px; height: 16px; flex: none; }
.pt-btn:hover { background: var(--subtle); color: var(--text); }
.pt-btn.on { background: var(--blue-soft); color: var(--blue); }
.pt-btn b { font-weight: 800; } .pt-btn i { font-family: Georgia, serif; font-size: 15px; }
.pt-size { min-width: 92px; justify-content: space-between; font-size: 13px; font-weight: 500; color: var(--text); }
.pt-size svg { width: 14px; height: 14px; color: var(--text-3); }
.pt-sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 4px; flex: none; }
.pt-anchor { position: relative; display: flex; align-items: center; gap: 2px; }
.pt-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 150px; padding: 5px; background: var(--card);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-pop); }
.pt-menu-item { display: block; width: 100%; text-align: left; padding: 6px 10px; border-radius: 7px; color: var(--text); }
.pt-menu-item:hover { background: var(--subtle); }
.pt-sz-2 { font-size: 13px; } .pt-sz-3 { font-size: 15px; } .pt-sz-5 { font-size: 20px; font-weight: 600; } .pt-sz-6 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.pt-swatch-menu { display: flex; gap: 7px; min-width: 0; padding: 8px; }
.pt-swatches { display: flex; gap: 6px; padding: 0 4px; }
.pt-swatch { width: 20px; height: 20px; border-radius: 50%; flex: none; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); transition: transform .1s; }
.pt-swatch:hover { transform: scale(1.12); }
.pt-swatch.on { outline: 2px solid var(--blue); outline-offset: 2px; }
.pt-swatch.none { background: linear-gradient(135deg, var(--card) 45%, var(--rose) 45%, var(--rose) 55%, var(--card) 55%); }
.pt-color-a { position: relative; font-weight: 600; padding-bottom: 3px; }
.pt-color-bar { position: absolute; left: -2px; right: -2px; bottom: -2px; height: 3px; border-radius: 2px; background: #1d1d1f; }
.pt-width span { display: block; border-radius: 50%; }

@media (max-width: 640px) {
  .portal-row { gap: 12px; padding: 12px 12px max(12px, var(--safe-bottom)); scroll-snap-type: x mandatory; }
  .pf { --pf-w: calc(100vw - 48px); scroll-snap-align: center; }
  .pf-doc { --pad-y: 18px; --pad-x: 18px; padding-bottom: 40px; }
}
