/* ============================================================================
   Conxfolio — V5 wave R4 · PORTFOLIO STUDIO  (§8–12, §26–29, §34)
   ----------------------------------------------------------------------------
   Additive on top of r3.css. Every rule is scoped to .portfolio-product, so
   removing this one <link> returns every other surface — and the portfolio
   studio's own R2/R3 skin — exactly as it was. No colour literal appears
   here; every value comes from assets/tokens.css.
   ========================================================================== */

/* ---------------------------------------------------------------- the shell
   The studio's three panes are sized from the viewport minus its chrome. R4
   adds one band (the source choice, §54 bug 16), so the chrome height becomes
   a variable rather than a number repeated in four calc()s. */
:root { --cx-strip-h: 0px; }
.portfolio-product { --pf-chrome: 118px; --pf-source: 0px; }
.portfolio-product[data-portfolio-source-bar="on"] { --pf-source: 98px; }
.portfolio-product { height: calc(100vh - var(--topbar-h) - var(--cx-strip-h)); }
.portfolio-product .portfolio-template-studio,
.portfolio-product .portfolio-content-studio,
.portfolio-product .portfolio-review-studio {
  height: calc(100vh - var(--topbar-h) - var(--cx-strip-h) - var(--pf-chrome) - var(--pf-source));
}
.portfolio-publish-panel > h1 { font-size: clamp(30px, 2.8vw, 42px); }

/* --------------------------------------------------- §34 · the studio toolbar
   Modes on the left, document actions on the right — the same row the cover
   letter studio uses, so one vocabulary reads the same in both places. */
.portfolio-studio-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(14px, 3vw, 44px);
  border-bottom: 1px solid var(--cx-line-strong);
  background: var(--cx-porcelain);
}
.portfolio-studio-toolbar .portfolio-modebar {
  flex: 0 1 auto;
  justify-content: flex-start;
  padding-left: 0;
  padding-right: 0;
  border-bottom: 0;
  background: transparent;
}
.portfolio-document-actions { display: flex; align-items: center; gap: 6px; }
.portfolio-document-actions .button { white-space: nowrap; }

/* ------------------------------------------------- §54 bug 16 · the source band
   Three cards of identical size, weight and voice. There is no badge, no
   ordering cue and no recommended member: §25 says a connection is a
   convenience, never a superior path. The only marked card is the one the
   visitor actually chose. */
.portfolio-source-band {
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(0, 2fr);
  align-items: center;
  gap: clamp(14px, 2vw, 34px);
  min-height: 98px;
  padding: 12px clamp(14px, 3vw, 44px);
  border-bottom: 1px solid var(--cx-line-strong);
  background: var(--cx-paper);
}
.portfolio-source-lede h2 {
  margin: 0 0 5px;
  font: 500 clamp(17px, 1.5vw, 21px)/1.05 var(--serif);
  letter-spacing: -.01em;
}
.portfolio-source-lede p { margin: 0; color: var(--cx-ink60); font-size: 11px; line-height: 1.4; }

/* the container class is the one r2.js already knows as a control group, so
   the selected member inherits the product's single active-state grammar. */
.portfolio-product .portfolio-source-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border-top: 0;
}
.portfolio-product .portfolio-source-actions > button {
  width: 100%;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  padding: 11px 13px;
  border: 1px solid var(--cx-line-strong);
  border-radius: 6px;
  background: var(--cx-paper);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}
.portfolio-product .portfolio-source-actions > button > b {
  font: 700 12px/1.2 var(--ui);
  color: var(--navy);
}
.portfolio-product .portfolio-source-actions > button > small {
  color: var(--cx-ink60);
  font-size: 10px;
  line-height: 1.35;
}
/* NOTE: the selected card's ink, weight, ground and marker are NOT set here.
   `.portfolio-source-actions` is a `row` group in the r2.js table, so R2's one
   active-state grammar paints it (with !important) exactly as it paints every
   other selected control in the product. R4 owns the geometry only — which is
   the whole point of §32: forty controls, one answer. */
.portfolio-product .portfolio-source-actions > button:hover {
  padding-left: 13px;
  border-color: var(--cx-accent);
}
.portfolio-product .portfolio-source-actions > button.on { padding-left: 13px; }
.portfolio-product .portfolio-source-actions > button:focus-visible {
  outline: 3px solid var(--cx-accent-a30);
  outline-offset: 2px;
}

/* --------------------------------------------- §54 bug 11 · the device switch
   One track, one raised thumb, labels a person can read, and targets that
   clear 40px at 390. The state itself lives in the record; this is only what
   it looks like. */
.portfolio-product .segmented.portfolio-device-switch {
  height: 34px;
  gap: 0;
  padding: 3px;
  border: 1px solid var(--cx-line-strong);
  border-radius: 999px;
  background: var(--cx-mist);
}
.portfolio-product .segmented.portfolio-device-switch button {
  min-height: 26px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--cx-ink60);
  font: 700 11px/1 var(--ui);
  letter-spacing: 0;
  text-transform: none;
}
/* …and the raised thumb is R2's `pill` marker, for the same reason. */
.portfolio-product .segmented.portfolio-device-switch button:hover { color: var(--navy); }
.portfolio-product .segmented.portfolio-device-switch button:focus-visible {
  outline: 3px solid var(--cx-accent-a30);
  outline-offset: 2px;
}
.portfolio-product .portfolio-live-preview > header { padding: 0 12px; }
.portfolio-product .portfolio-live-preview { grid-template-rows: 46px 1fr; }

/* ------------------------------------------- §8 · the selection and its button */
.portfolio-product .portfolio-template-next > span > i {
  border-color: var(--cx-accent);
  color: var(--cx-accent);
  font: 700 10px/1 var(--mono);
}
.portfolio-product .portfolio-template-next small { color: var(--cx-ink60); }

/* ---------------------------------------- §10 · the content rail, work first */
.portfolio-work-focus > header .button { white-space: nowrap; }
.portfolio-outline-advanced { margin-top: 10px; border-top: 1px solid var(--cx-line-strong); }
.portfolio-outline-advanced > summary {
  padding: 11px 9px;
  color: var(--cx-ink60);
  font: 700 9px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}
.portfolio-outline-advanced > summary:focus-visible { outline: 3px solid var(--cx-accent-a30); outline-offset: -3px; }


/* ------------------------------ §29 · suggestions instead of blank boxes */
.portfolio-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.portfolio-suggest > span {
  color: var(--cx-ink60);
  font: 700 8px/1 var(--mono);
  letter-spacing: .07em;
  text-transform: uppercase;
}
.portfolio-suggest .button {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------- §12 · bug 17 · publishing */
.portfolio-publish-panel > h1 { margin-bottom: 10px; }
.portfolio-publish-lede { margin: 0 0 18px; color: var(--cx-ink60); font-size: 12px; line-height: 1.5; }
.portfolio-publish-live-url {
  margin: 0 0 18px;
  padding: 11px 12px;
  border: 1px solid var(--cx-line-strong);
  background: var(--cx-paper);
  font: 700 12px/1 var(--mono);
  word-break: break-all;
}
.portfolio-publish-steps { margin: 0 0 14px; padding: 0; list-style: none; }
.portfolio-publish-steps > li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--cx-line-strong);
}
.portfolio-publish-steps > li:last-child { border-bottom: 1px solid var(--cx-line-strong); }
.portfolio-step-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--cx-line-strong);
  border-radius: 50%;
  color: var(--cx-accent);
  font: 700 10px/1 var(--mono);
}
.portfolio-publish-steps .field { margin-bottom: 0; }
.portfolio-handle-preview {
  display: block;
  margin-top: 7px;
  font: 700 11px/1 var(--mono);
  word-break: break-all;
}
.portfolio-publish-panel [data-handle-state] { display: block; margin: 6px 0 0; font-size: 10px; }
.portfolio-publish-panel [data-handle-state][data-handle-status="available"] { color: var(--cx-ok-fg); }
.portfolio-publish-panel [data-handle-state][data-handle-status="taken"],
.portfolio-publish-panel [data-handle-state][data-handle-status="invalid"] { color: var(--cx-stop-fg); }
.portfolio-publish-readiness {
  margin: 12px 0 0;
  color: var(--cx-ink60);
  font: 700 9px/1.5 var(--mono);
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* the honest line about a server that holds one published page per email */
.portfolio-replace-note {
  display: grid;
  gap: 9px;
  margin: 0 0 18px;
  padding: 13px 14px;
  border: 1px solid var(--cx-ask-fg);
  background: var(--cx-ask-bg);
}
.portfolio-replace-note > b { color: var(--cx-ask-fg); font: 700 12px/1.45 var(--ui); }
.portfolio-replace-actions { display: grid; gap: 7px; }
.portfolio-replace-actions > small { color: var(--cx-ask-fg); font-size: 10px; line-height: 1.5; }
.portfolio-replace-actions .button[disabled] {
  justify-self: start;
  border-style: dashed;
  cursor: not-allowed;
}

/* --------------------------------------------------------------- 390 and down */
@media (max-width: 820px) {
  .portfolio-product[data-portfolio-source-bar="on"] { --pf-source: 0px; }
  .portfolio-product { height: auto; }
  /* the viewport-derived heights above are a DESKTOP arrangement. Below 820
     the three panes stack and size themselves from their content — styles.css
     already says so, but it says it with a lower-specificity selector, so
     these must be restated here or the R4 rule would squash the stacked
     panes (the publish preview collapsed to ~130px before this line). */
  .portfolio-product .portfolio-template-studio,
  .portfolio-product .portfolio-content-studio,
  .portfolio-product .portfolio-review-studio { height: auto; }
  /* NOT sticky at 390: a `header` inside this product already inherits
     `position: relative; top: var(--topbar-h)` from the premium layer, which
     shifted the whole toolbar 104px DOWN over the band beneath it and left a
     hole where the tabs belong. One static row, stated explicitly. */
  .portfolio-product .portfolio-studio-toolbar {
    position: static;
    top: auto;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }
  /* the modebar was its own sticky element at 390; inside the R4 toolbar that
     made it stick to a coordinate ABOVE its container and leave a hole where
     the tabs should be. Neither is sticky now — the row simply scrolls. */
  .portfolio-studio-toolbar .portfolio-modebar { position: static; width: 100%; height: auto; padding: 0; }
  .portfolio-studio-toolbar .portfolio-modebar button { width: 33.333%; }
  /* …and the pane below no longer reserves a strip for it. */
  .portfolio-product .portfolio-content-studio { padding-top: 0; }
  .portfolio-document-actions { width: 100%; justify-content: flex-start; }
  .portfolio-document-actions .button { flex: 1 1 0; min-height: 40px; }
  .portfolio-source-band { grid-template-columns: 1fr; gap: 12px; padding: 16px 12px; }
  .portfolio-product .portfolio-source-actions { grid-template-columns: 1fr; }
  .portfolio-product .portfolio-source-actions > button { min-height: 62px; border-right: 1px solid var(--cx-line-strong); }
  .portfolio-product .segmented.portfolio-device-switch { height: 40px; }
  .portfolio-product .segmented.portfolio-device-switch button { min-height: 32px; padding: 0 14px; }
  /* the content rail runs horizontally at 390; the Advanced disclosure is one
     more stop on it, not a footer under it. */
  .portfolio-outline-advanced {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    margin-top: 0;
    border-top: 0;
    border-left: 1px solid var(--cx-line-strong);
  }
  .portfolio-outline-advanced > summary { padding: 0 14px; }
  .portfolio-outline-advanced[open] { flex-direction: column; align-items: stretch; justify-content: center; }
  .portfolio-outline-advanced[open] > summary { padding: 8px 14px 4px; }
}
