/* The Back / Next bar (with its quiet "Pricing, optional" on Book a call), the phone switch between
   Details and Your first look, and Building's phone layout. Built on the tokens in shell.css. */

/* ---------- The left column: the screen, then the bar at its foot ---------- */
.side { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side > .panel { flex: 1 1 auto; }

/* ---------- Back / Next ---------- */
.stepbar[hidden] { display: none; }
.stepbar__in { display: flex; align-items: center; gap: 12px; }
.stepbar__back {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  min-width: 48px; min-height: 48px; padding: 0 16px 0 12px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1;
  transition: border-color .15s, background-color .15s;
}
.stepbar__back:hover { border-color: var(--navy); }
.stepbar__back svg, .stepbar__next svg { width: 16px; height: 16px; flex: none; }
.stepbar__next { margin-left: auto; min-width: 0; gap: 8px; padding-inline: 20px 16px; }
.stepbar__next > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The way on to the optional step is words with a small arrow, never a filled button: nobody is
   stuck, and nothing competes with the screen's own action. */
.stepbar__quiet {
  display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; flex: 0 1 auto;
  margin-left: auto; min-width: 0; min-height: 48px; padding: 0 2px 0 8px;
  border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.2; text-align: right;
}
.stepbar__quiet > span { min-width: 0; }
.stepbar__opt { font-weight: 400; color: var(--muted); }
.stepbar__quiet svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.stepbar__quiet:hover > span { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.stepbar__score {
  display: none; flex: none; align-content: center; min-height: 48px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--cream);
  color: var(--ink); text-decoration: none; line-height: 1.15;
}
.stepbar__score-label { font-size: 14px; color: var(--muted); }
.stepbar__score-num { font-size: 17px; font-weight: 700; color: var(--gold-text); font-variant-numeric: tabular-nums; }
.stepbar__score:hover .stepbar__score-label { text-decoration: underline; text-underline-offset: 3px; }
.is-last .stepbar__score { margin-left: auto; }

/* Laptops: the foot of the left column, the same spot on every step. */
@media (min-width: 901px) {
  .stepbar { flex: none; margin-top: 4px; padding: 12px 0 0; border-top: 1px solid var(--line); background: var(--bg); }
  .stepbar__back, .stepbar__next.btn--lg, .stepbar__quiet { min-height: 44px; }
  /* Notes appear at the top of the window here, never over the bar's Next. */
  .toast { top: calc(var(--header-h) + 14px); bottom: auto; transform: translate(-50%, -8px); }
  .toast.is-on { transform: translate(-50%, 0); }
}
/* Tablets and small laptops scroll the page, so the bar sticks to the bottom of the window. */
@media (min-width: 901px) and (max-width: 1180px) {
  .stepbar { position: sticky; bottom: 0; z-index: 5; padding-bottom: 16px; }
}

/* ---------- Phones: one bar fixed to the bottom of the screen ---------- */
@media (max-width: 900px) {
  .stepbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(44, 51, 64, .07);
  }
  .stepbar__score { display: grid; }
  .stepbar__next { flex: 1 1 auto; padding-inline: 16px 12px; font-size: 15px; }
  /* The page never hides under the bar, and toasts sit just above it. */
  body.has-bar .stage { padding-bottom: calc(68px + 32px + env(safe-area-inset-bottom)); }
  body.has-bar .toast { bottom: calc(68px + 14px + env(safe-area-inset-bottom)); font-size: 15px; }
  /* Over the first look, toasts clear its "Scroll through your page" button too. */
  body[data-pane="look"] .toast { bottom: calc(68px + 70px + env(safe-area-inset-bottom)); }
  /* With the switch shown, its own spacing does the work of the column gap. */
  body:is([data-pane="details"], [data-pane="look"]) .stage { row-gap: 0; }
  /* The bottom of the screen holds one bar: the score's slim strip gives way to it. */
  body.has-bar .strip--slim { display: none; }
  /* While the keyboard is up, the bar steps aside so it can never cover what they type. */
  body.has-bar.is-typing .stepbar { display: none; }
}
/* Small phones: Back is its arrow alone (it is still called "Back to ..." for screen readers), and
   the bar's parts sit a little closer so Back, the score, and "Pricing, optional" share one line. */
@media (max-width: 399px) {
  .stepbar__in { gap: 8px; }
  .stepbar__score { padding: 0 10px; }
  .stepbar__quiet { padding: 0; gap: 4px; }
  .stepbar__back { padding: 0; }
  .stepbar__back > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* A heading focused after moving to a new screen shows no ring (it isn't a control). */
.panel h1[tabindex="-1"]:focus { outline: none; }
/* Touch screens keep no hover color on a button after it is tapped (the bar's Next is redrawn under the finger). */
@media (hover: none) { .btn--dark:hover { background: var(--navy); } .btn:not(.btn--dark):hover { background: var(--surface); } }
@media (min-width: 901px) { .stepbar { position: relative; z-index: 2; } }

/* ---------- Phones: Details / Your first look ---------- */
.panes[hidden] { display: none; }
@media (min-width: 901px) { .panes { display: none; } }
@media (max-width: 900px) {
  .panes {
    position: sticky; top: 8px; z-index: 12;
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    margin: -8px 0 16px; padding: 4px;
    border-radius: var(--radius); background: var(--tint-strong);
    box-shadow: 0 0 0 8px var(--bg);   /* the page's own color around it, so nothing shows through above */
  }
  .panes__tab {
    position: relative; min-height: 44px; padding: 0 10px;
    border: 0; border-radius: var(--radius-sm); background: transparent;
    color: var(--text); font-size: 15px; font-weight: 600; white-space: nowrap;
    transition: background-color .2s, color .2s, box-shadow .2s;
  }
  .panes__tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(44, 51, 64, .12); }
  .panes__cue {
    position: absolute; top: -9px; right: 6px; padding: 1px 8px;
    border-radius: var(--radius-pill); background: var(--green); color: #fff;
    font-size: 14px; font-weight: 600; line-height: 1.4;
    opacity: 0; transform: translateY(3px); pointer-events: none;
    transition: opacity .2s, transform .2s;
  }
  .panes__tab.is-updated .panes__cue { opacity: 1; transform: none; }
  .panes__tab.is-updated:not([aria-selected="true"]) { color: var(--ink); background: var(--green-soft); }

  body[data-pane="details"] .view { display: none; }
  body[data-pane="look"] .side > .panel { display: none; }
  /* The first look fills the screen between the switch and the bar, and scrolls inside itself. */
  body[data-pane="look"] .frame { flex: none; height: calc(100dvh - 76px - 68px - 16px - env(safe-area-inset-bottom)); min-height: 320px; }
  body[data-pane="look"] .frame__body { max-height: none; }
  body[data-pane="look"] .view__above:has(> .principles) { order: 4; margin-top: 8px; }
}

/* ---------- Phones: Building leads with the drawing ----------
   The left column's parts are laid out one by one so the first look sits right under the two
   progress bars, with the workers' notes and the two questions below it. */
@media (max-width: 900px) {
  body[data-route="progress"] :is(.side, .panel, .prog) { display: contents; }
  body[data-route="progress"] .stage { display: flex; flex-direction: column; gap: 0; }
  body[data-route="progress"] .crumb { order: 1; }
  body[data-route="progress"] .prog__head { order: 2; }
  body[data-route="progress"] .view { order: 3; margin-top: 16px; }
  body[data-route="progress"] .wk-notes { order: 4; }
  body[data-route="progress"] .prog__ask { order: 5; }
  body[data-route="progress"] .frame__bar { flex-wrap: nowrap; }
  body[data-route="progress"] .frame__titles { flex-basis: auto; }
  body[data-route="progress"] .frame__body { height: clamp(200px, calc(100dvh - 420px), 460px); max-height: none; }
}
