/* The bomfab.com front door. Loaded last by index.html only, so it restyles
   the workbench without touching demo60, assembly or local-demo.

   Signed out, the page is a teaser with one action: sign in with BOMForge.
   The beta is for BOMForge customers, so the workbench below only exists for
   an account the Worker recognises.

   The page used to open on a form: a navy wizard headline, three buttons that
   all said "Upload photo", an email form and an API key form stacked under
   the file picker, and a fixed "next step" bar sitting on top of the email
   field. This file gives it one hero, one primary action per screen, and the
   setup steps in their own column. Every id app.js and demo-workflow.js read
   is unchanged; this is presentation only. */

/* The one colour this file names. Forge red on the near-black shell is about
   3:1, which fails AA for text this small, so the hero eyebrow uses a lighter
   tint of the same hue. Everything else here comes from tokens.css. */
:root {
  --red-on-shell: #ff5a76;
}

/* ---- The signed-out gate -------------------------------------------------
/* The signed-out front door. auth-client.ts shows this section and hides
   #workspace until a BOMForge account is verified, so this IS the page a
   visitor meets: the teaser on the left, the sign-in card on the right. */
.auth-gate {
  /* style.css and demo-workflow.css both cap this section at 1080px for the
     old light layout. The dark band has to reach both edges. */
  max-width: none;
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  align-items: start;
  gap: clamp(32px, 5vw, 72px);
  padding: clamp(48px, 7vw, 96px) max(24px, calc((100vw - 1180px) / 2));
  background: var(--shell);
  color: var(--ink-inverse);
}
.bf-eyebrow {
  margin: 0 0 20px;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--red-on-shell);
}
.auth-gate h1 {
  margin: 0;
  font-family: var(--font-display);
  font-stretch: var(--display-stretch, 100%);
  font-weight: 800;
  /* The copy column is about 590px at the widest, and the second line is the
     long one. Archivo carries a width axis, so the hero takes a condensed cut
     rather than a smaller size: at 88% the line holds to 64px, where the UI's
     112% broke it into four lines at 62px. Measured at 1440, 1280, 1100 and
     980. Inter Tight, the fallback, has no width axis and simply sets a
     little wider at the same size, which this cap still clears. */
  font-stretch: 88%;
  font-size: clamp(36px, 4.2vw, 60px);
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.auth-gate .bf-hero-lead {
  max-width: 540px;
  margin: 24px 0 0;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--ink-inverse-muted);
}
.auth-gate .bf-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  margin-top: 36px;
}
.bf-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 28px;
  border-radius: var(--r-sm);
  background: var(--red);
  color: var(--ink-inverse);
  font-size: var(--fs-base);
  font-weight: 650;
  cursor: pointer;
  transition: background 0.16s;
}
.bf-cta:hover {
  background: var(--red-hover);
}
.bf-cta:focus-visible,
.bf-ghost:focus-visible {
  outline: 2px solid var(--ink-inverse);
  outline-offset: 4px;
}
.bf-ghost {
  color: var(--ink-inverse);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--line-shell);
  padding-bottom: 3px;
}
.bf-ghost::after {
  content: " →";
}
.bf-ghost:hover {
  border-bottom-color: var(--ink-inverse);
}
.bf-formats {
  margin: 28px 0 0;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.06em;
  color: var(--ink-inverse-muted);
}
.auth-gate .bf-hero-figure {
  position: relative;
  margin: 28px 0 0;
  border: 1px solid var(--line-shell);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--line-strong);
}
.auth-gate .bf-hero-figure img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.auth-gate .bf-hero-figure figcaption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--shell) 88%, transparent);
  color: var(--ink-inverse);
  font-size: var(--fs-sm);
  font-weight: 600;
  border-left: 3px solid var(--red);
}
.auth-gate .bf-hero-figure figcaption span {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-inverse-muted);
}

/* ---- The sign-in card on the dark gate ---------------------------------- */
.auth-gate .auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 28px;
  box-shadow: var(--shadow-overlay);
  position: sticky;
  top: 32px;
}
.auth-gate .auth-card-label {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 14px;
}
.auth-gate .auth-card h2 {
  font-family: var(--font-display);
  font-stretch: 88%;
  font-weight: 800;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--ink);
}
.auth-gate .auth-card p {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.auth-gate .auth-card .primary {
  min-height: 52px;
  background: var(--red);
  border-color: var(--red);
  color: var(--ink-inverse);
  font-weight: 650;
}
.auth-gate .auth-card .primary:hover:not(:disabled) {
  background: var(--red-hover);
  border-color: var(--red-hover);
}
.auth-gate .auth-support {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 18px;
  font-size: var(--fs-xs);
}
.auth-gate .bf-formats {
  margin-top: 22px;
}
@media (max-width: 860px) {
  .auth-gate {
    grid-template-columns: minmax(0, 1fr);
    padding-block: 36px 40px;
  }
  .auth-gate .auth-card {
    position: static;
  }
  .auth-gate h1 br {
    display: none;
  }
}

/* ---- Workflow chrome ---------------------------------------------------- */
.workspace-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
  padding: 22px 24px;
  background: var(--shell);
  color: var(--ink-inverse);
  border-radius: var(--r-sm);
  border-top: 3px solid var(--red);
}
.workspace-overview[hidden] {
  display: none;
}
.workspace-eyebrow {
  margin: 0 0 8px;
  font: 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-inverse-muted);
}
.workspace-identity h2 {
  margin: 0;
  font: 700 22px/1.2 var(--font-display);
  overflow-wrap: anywhere;
}
.workspace-identity > p:last-child {
  margin: 8px 0 0;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--ink-inverse-muted);
}
.workspace-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  margin: 0;
  gap: 22px;
}
.workspace-counts dt {
  font-size: 11px;
  color: var(--ink-inverse-muted);
}
.workspace-counts dd {
  margin: 6px 0 0;
  font: 500 26px/1 var(--font-mono);
}
@media (max-width: 860px) {
  .workspace-overview {
    grid-template-columns: minmax(0, 1fr);
    padding: 18px;
    gap: 20px;
  }
  .workspace-counts {
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .workspace-identity h2 {
    font-size: 20px;
  }
  .workflow-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }
  .workflow-steps button {
    min-width: 0;
    white-space: normal;
    padding: 12px 6px;
    gap: 5px;
  }
  .workflow-steps button[data-workflow-step="refine"] {
    grid-column: 1 / -1;
    min-height: 44px;
  }
}
/* Undo, Export and Save act on a BOM. style.css hid them on phones only; with
   nothing to act on they are noise at every width. */
body:not([data-has-parts]) #workspace-actions {
  display: none;
}
.workflow-steps button[aria-current="step"] {
  border-bottom-color: var(--red);
  color: var(--ink);
}
.workflow-steps button[aria-current="step"] span {
  color: var(--red);
}
.workflow-next h2 {
  font-family: var(--font-display);
  font-stretch: var(--display-stretch, 100%);
  font-weight: 750;
  color: var(--ink);
  letter-spacing: -0.02em;
}
body[data-workflow-step] .primary {
  background: var(--red);
  border-color: var(--red);
  color: var(--ink-inverse);
}
body[data-workflow-step] .primary:hover:not(:disabled) {
  background: var(--red-hover);
  border-color: var(--red-hover);
}
body[data-workflow-step] .primary:disabled {
  background: var(--faint);
  border-color: var(--faint);
}

/* The fixed dock repeated the headline button and covered the email field.
   On a wide screen the headline button is always in reach, so the dock goes.
   On a phone it stays, and the page reserves room so it covers nothing. */
@media (min-width: 861px) {
  .workflow-dock {
    display: none !important;
  }
}
@media (max-width: 860px) {
  body[data-workflow-step] #workspace {
    padding-bottom: 132px;
  }
  body[data-workflow-step="upload"]:not([data-has-parts]):not(:has(#photos > *))
    .workflow-dock {
    display: none;
  }
}

/* ---- Upload step: the file on the left, setup on the right --------------- */
body[data-workflow-step="upload"] #upload-panel .visual {
  height: 240px;
  cursor: pointer;
  background-image: var(
    --dot-grid,
    radial-gradient(var(--line) 0.75px, transparent 0.75px)
  );
  background-size: var(--dot-size, 18px) var(--dot-size, 18px);
}
body[data-workflow-step="upload"] .placeholder h2 {
  font-family: var(--font-display);
  font-stretch: var(--display-stretch, 100%);
  font-weight: 750;
}
body[data-workflow-step="upload"] #upload-panel label.upload:has(#photo) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ink-inverse);
  font-weight: 650;
}
.bf-setup {
  padding: 22px 24px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-sunken);
}
.bf-setup-kicker {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.bf-setup .signup-card {
  margin: 0;
  padding: 0 0 18px;
  border: 0;
  background: none;
}
.bf-setup .signup-title {
  font-family: var(--font-display);
  font-stretch: var(--display-stretch, 100%);
  font-size: var(--fs-md);
  font-weight: 750;
  color: var(--ink);
}
.bf-setup .key-settings,
body[data-workflow-step] .bf-setup .key-settings {
  margin-top: 0;
}
.bf-setup .key-settings summary {
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 650;
}
.bf-key-fine {
  margin-top: 10px;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.bf-key-fine summary {
  cursor: pointer;
}
body[data-workflow-step]:not([data-workflow-step="upload"]) .bf-setup {
  display: none;
}
@media (min-width: 980px) {
  body[data-workflow-step="upload"] #upload-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    /* The setup column is taller than the file column. Give the extra height
       to the last row, or it is shared out as a gap under the drop zone. */
    grid-template-rows: auto auto 1fr;
    align-items: start;
  }
  body[data-workflow-step="upload"] #upload-panel > .section-title {
    grid-column: 1 / -1;
  }
  body[data-workflow-step="upload"] #upload-panel > .visual,
  body[data-workflow-step="upload"] #upload-panel > .body {
    grid-column: 1;
  }
  body[data-workflow-step="upload"] #upload-panel > .body {
    max-width: none;
    margin: 0;
    padding: 22px 28px 26px;
  }
  body[data-workflow-step="upload"] #upload-panel > .bf-setup {
    grid-column: 2;
    grid-row: 2 / span 2;
    align-self: stretch;
    border-top: 0;
    border-left: 1px solid var(--line);
  }
}

/* ---- Status toast --------------------------------------------------------
   It was a full-width translucent white bar pinned to the bottom edge, which
   blurred over whatever row sat under it. A small dark toast covers less and
   reads as a message rather than as part of the form. */
body[data-workflow-step] #status {
  left: 24px;
  right: auto;
  bottom: 24px;
  width: auto;
  max-width: min(560px, calc(100% - 48px));
  margin: 0;
  padding: 10px 16px;
  background: var(--shell);
  color: var(--ink-inverse);
  border: 1px solid var(--line-shell);
  border-radius: var(--r-sm);
  backdrop-filter: none;
  box-shadow: var(--shadow-overlay);
  font-size: var(--fs-xs);
}
@media (max-width: 860px) {
  body[data-workflow-step] #status {
    left: 16px;
    max-width: calc(100% - 32px);
    bottom: 124px;
  }
}

/* ---- Footer -------------------------------------------------------------- */
.bf-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 32px;
  margin-top: 64px;
  padding: 28px max(24px, calc((100vw - 1180px) / 2));
  border-top: 3px solid var(--red);
  background: var(--shell);
  color: var(--ink-inverse-muted);
  font-size: var(--fs-sm);
}
.bf-footer p {
  margin: 0;
}
.bf-footer a {
  color: var(--ink-inverse);
}
.bf-footer .site-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 0;
  font-size: var(--fs-sm);
  color: inherit;
}
.bf-footer .site-legal a {
  color: var(--ink-inverse-muted);
  text-decoration: none;
}
.bf-footer .site-legal a:hover {
  color: var(--ink-inverse);
}

/* ---- Narrow ------------------------------------------------------------- */
@media (max-width: 860px) {
  .auth-gate .bf-hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* The Wi-Fi fallback is a footnote under the card, not a banner over the
   primary action. */
.auth-gate .connection-help {
  margin-top: 16px;
  font-size: var(--fs-xs);
  color: var(--muted);
}
