/* cloud-things — single self-hosted stylesheet. No build step, no CDN, no JS.
   Kept intentionally small: the CSP allows only 'self' styles. */

:root {
  --bg: #0f1419;
  --panel: #1a2029;
  --panel-2: #222b36;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #4ea1ff;
  --accent-ink: #04121f;
  --border: #2c3947;
  --danger: #ff6b6b;
  --ok: #4caf7d;
  --radius: 10px;
  --wrap: 880px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  /* Sticky footer: main stretches, footer rides the bottom on short pages. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem;
}
.skip-link:focus { left: 0; z-index: 10; }

/* Header / nav — auto-hiding sticky header: rides the top of the viewport,
   slides away scrolling down, reappears over content on scroll-up. */
.site-header { border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0; z-index: 50;
  transition: transform .22s ease; }
.site-header.header-hidden { transform: translateY(-100%); }
/* Header + footer keep ONE width everywhere (the wide one), so navigation
   never makes them jump; only the content column varies per page type. */
.site-header .wrap, .site-footer .wrap { max-width: 1180px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: .9rem; padding-bottom: .9rem; }
.brand { font-weight: 700; font-size: 1.25rem; color: var(--text); }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; align-items: center; }
.nav a { color: var(--muted); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.nav .linklike { background: none; border: none; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.nav .linklike:hover { color: var(--text); text-decoration: underline; }

/* Sections */
main.wrap { padding: 2.5rem 1.25rem 3.5rem; flex: 1 0 auto; }
.hero { text-align: center; padding: 1.5rem 0 2.5rem; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 .5rem; }
.lede { color: var(--muted); font-size: 1.15rem; max-width: 46ch; margin: 0 auto 1.5rem; }

.hero-actions .btn { margin: .3rem .35rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.card h2 { font-size: 1.1rem; margin: 0 0 .4rem; }
.card p { color: var(--muted); margin: 0; }

.callout { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem 1.75rem; margin-top: 2.5rem; text-align: center; }
.callout h2 { margin: 0 0 .6rem; font-size: 1.4rem; }
.callout p { color: var(--muted); max-width: 62ch; margin: 0 auto 1.2rem; }

.prose { max-width: 60ch; }
.prose h1 { margin-top: 0; }

/* Floating printed parts — decorative home-page background. Fixed layer behind
   all content (negative z-index), pure CSS animation over inline SVG. Panels
   (cards, header, footer) naturally cover it. */
.floating-parts { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.fp { position: absolute; opacity: .6; }
.fp svg { display: block; width: 100%; height: 100%; }
.fp-gear { top: 16%; left: 3%; width: 180px; height: 180px; animation: fp-drift-a 24s ease-in-out infinite alternate; }
.fp-gear svg { animation: fp-spin 140s linear infinite; }
.fp-nut  { top: 9%;  right: 7%; width: 90px;  height: 90px;  animation: fp-drift-b 19s ease-in-out infinite alternate; }
.fp-cube { top: 46%; right: 12%; width: 130px; height: 130px; animation: fp-drift-c 28s ease-in-out infinite alternate; }
.fp-boat { bottom: 14%; left: 9%; width: 150px; height: 127px; animation: fp-drift-b 16s ease-in-out infinite alternate-reverse; }
.fp-boat svg { animation: fp-bob 7s ease-in-out infinite; }
.fp-vase { bottom: 7%; right: 4%; width: 100px; height: 120px; animation: fp-drift-a 21s ease-in-out infinite alternate-reverse; }
.fp-ring { top: 6%; left: 32%; width: 70px; height: 70px; animation: fp-drift-c 22s ease-in-out infinite alternate; }
.fp-ring svg { animation: fp-spin 60s linear infinite reverse; }

@keyframes fp-drift-a {
  from { transform: translate3d(0, 0, 0) rotate(-5deg); }
  to   { transform: translate3d(30px, -48px, 0) rotate(6deg); }
}
@keyframes fp-drift-b {
  from { transform: translate3d(0, 0, 0) rotate(4deg); }
  to   { transform: translate3d(-36px, 40px, 0) rotate(-7deg); }
}
@keyframes fp-drift-c {
  from { transform: translate3d(0, 0, 0) rotate(-3deg); }
  to   { transform: translate3d(22px, 54px, 0) rotate(8deg); }
}
@keyframes fp-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-9px) rotate(-2deg); }
}
@keyframes fp-spin { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  /* Fewer, calmer parts on small screens. */
  .fp-ring, .fp-cube, .fp-nut { display: none; }
  .fp { opacity: .4; }
}
@media (prefers-reduced-motion: reduce) {
  .fp, .fp svg { animation: none; }
}

/* Operator console: data-dense pages get the full page width. */
body.wide { --wrap: 1180px; }
.ops-tabs, .tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 1.25rem; }
.ops-filter { display: flex; gap: .8rem; flex-wrap: wrap; align-items: end; margin: 0 0 1.25rem; }
.ops-table { width: 100%; border-collapse: collapse; }
.ops-table th, .ops-table td { padding: .55rem .65rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.ops-table thead th { white-space: nowrap; color: var(--muted); font-size: .9rem; }
.ops-table .nowrap { white-space: nowrap; }
.ops-table form { margin: 0; }
.ops-table .btn { padding: .35rem .85rem; }
.pager { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 1.25rem 0; }
.btn-disabled { opacity: .4; pointer-events: none; }
/* Detail: two columns on wide screens — content left, actions right. */
.ops-detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 820px) { .ops-detail-grid { grid-template-columns: 1fr; } }
.about-banner { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); margin: 0 0 2rem; }

/* Buttons */
.btn { display: inline-block; padding: .7rem 1.4rem; border-radius: var(--radius); font-weight: 600; border: 1px solid var(--border); cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { text-decoration: none; filter: brightness(1.08); }

/* Forms */
.form { max-width: 640px; }
.form h1 { margin-top: 0; }
.field { margin: 0 0 1.25rem; }
.field > label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field .hint { display: block; color: var(--muted); font-size: .9rem; margin-bottom: .45rem; }
.field input[type=text], .field input[type=email], .field input[type=tel],
.field input[type=url], .field input[type=number], .field input[type=date],
.field textarea, .field select {
  width: 100%; padding: .6rem .7rem; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
.field textarea { min-height: 7rem; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field .req { color: var(--accent); }
.check { display: flex; gap: .6rem; align-items: flex-start; }
.check input { margin-top: .3rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--panel); margin-top: auto; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2rem; padding-top: 2.2rem; padding-bottom: 1.2rem; }
.footer-brand { font-weight: 700; font-size: 1.15rem; margin: 0 0 .4rem; }
.footer-brand span { color: var(--accent); }
.footer-head { font-weight: 600; margin: 0 0 .5rem; color: var(--text); }
.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li { margin: 0 0 .35rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }
.footer-grid .hint { max-width: 34ch; }
.footer-legal { border-top: 1px solid var(--border); padding-top: 1rem; padding-bottom: 1.4rem; color: var(--muted); font-size: .9rem; }
.footer-legal p { margin: 0; }

/* Presence + on-site chat */
.presence-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .35rem; vertical-align: baseline; }
.presence-dot.on { background: var(--ok); box-shadow: 0 0 6px rgba(76,175,125,.8); }
.presence-dot.off { background: var(--border); }
.chat-page { max-width: 760px; }
.chat-presence { margin: .3rem 0 .8rem; }
.chat-messages { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: .75rem; }
.chat-msg { max-width: 85%; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-msg.theirs { align-self: flex-start; }
.chat-meta { font-size: .85rem; color: var(--muted); margin-bottom: .15rem; }
.chat-body { display: inline-block; text-align: left; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .8rem; white-space: pre-wrap; word-break: break-word; }
.chat-msg.mine .chat-body { background: rgba(78,161,255,.16); border-color: rgba(78,161,255,.4); }
.chat-form { display: flex; gap: .6rem; align-items: flex-end; margin-top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Honeypot — visually and semantically hidden from real users. */
.hp { position: absolute; left: -5000px; width: 1px; height: 1px; overflow: hidden; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem 1.25rem; margin: 0 0 1.25rem; }
legend { padding: 0 .4rem; font-weight: 600; }

/* Flash / errors */
.flash { padding: .9rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.5rem; border: 1px solid; }
.flash-error { background: rgba(255,107,107,.1); border-color: var(--danger); color: #ffd7d7; }
.flash-ok { background: rgba(76,175,125,.12); border-color: var(--ok); color: #cfeede; }
.errors { color: var(--danger); margin: .3rem 0 0; padding-left: 1.1rem; }
.errors li { font-size: .92rem; }

/* Confirmation */
.confirm { text-align: center; padding: 2rem 0; }
.confirm .badge { font-size: 2.5rem; }
.order-id { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: var(--panel-2); padding: .15rem .5rem; border-radius: 6px; border: 1px solid var(--border); }

/* Order wizard --------------------------------------------------------- */
/* Base (no-JS): everything visible = one long form that still submits.
   The alternate step-3 title fragments stay hidden so the heading reads
   cleanly; JS reveals the right one per mode. */
.s3-intake, .s3-consultant, .s3-highvolume { display: none; }
.step-title { font-size: 1.15rem; margin: 0 0 1rem; color: var(--muted); }

.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.mode-card { display: flex; flex-direction: column; gap: .3rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); cursor: pointer; }
.mode-card:hover { border-color: var(--accent); }
.mode-card input { position: absolute; opacity: 0; }
.mode-card:has(input:checked) { border-color: var(--accent); background: var(--panel-2); outline: 2px solid var(--accent); }
.mode-title { font-weight: 600; }
.mode-desc { color: var(--muted); font-size: .9rem; }

.step-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.step-dots { color: var(--muted); font-size: .9rem; }

/* JS-enhanced: step + mode driven visibility. */
.wizard.js .wizard-step { display: none; }
.wizard.js .wizard-step.active { display: block; }
.wizard.js .easy-fields { display: none; }
.wizard.js[data-mode="easy"] .easy-fields,
.wizard.js[data-mode="advanced"] .easy-fields { display: block; }
/* "I have opinions" is no longer a mode — it's the collapsed per-item
   advanced section. Closed = our call; open + set = the customer's call. */
.adv-settings { margin: .8rem 0 .4rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .8rem; }
.adv-settings summary { cursor: pointer; color: var(--muted); font-size: .92rem; }
.adv-settings[open] summary { color: var(--text); margin-bottom: .4rem; }
.wizard.js #intake-area { display: none; }
.wizard.js[data-mode="consultant"] #items-area,
.wizard.js[data-mode="highvolume"] #items-area { display: none; }
.wizard.js[data-mode="consultant"] #intake-area,
.wizard.js[data-mode="highvolume"] #intake-area { display: block; }
.wizard.js .order-only { display: none; }
.wizard.js[data-mode="easy"] .order-only,
.wizard.js[data-mode="advanced"] .order-only { display: flex; }
/* Items: with JS, blocks live hidden in #items-store and are edited one at a
   time inside a modal; committed items render as table rows. Without JS the
   inline fieldsets remain a plain long form. */
.items-ui { display: none; }
.wizard.js .items-ui { display: block; }
.wizard.js #items-store .item-block { display: none; }
.wizard.js.show-all #items-store .item-block.shown { display: block; }
#item-modal-slot .item-block { display: block !important; border: none; padding: 0; margin: 0; }
#item-modal-slot legend { display: none; }
.item-modal { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: min(620px, 92vw); max-height: 86vh; overflow-y: auto; }
.item-modal::backdrop { background: rgba(4, 8, 12, .7); }
.item-modal-actions { display: flex; gap: .8rem; margin-top: 1rem; }
/* Drag & drop zone (items step) */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: .25rem; transition: border-color .15s, background .15s; }
.dropzone.dragover { border-color: var(--accent); background: rgba(78,161,255,.07); }

/* Model preview + instant-upload UI */
.model-preview, .ops-preview { margin: .8rem 0; }
/* Item card: details on the left, preview pinned to the right. */
.item-split { display: flex; gap: 1.2rem; align-items: flex-start; flex-wrap: wrap; }
.item-split .item-info { flex: 1 1 240px; min-width: 0; }
.item-split .ops-preview, .item-split .item-image { flex: 0 0 auto; margin: 0; }
.model-preview canvas, .ops-preview canvas { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); max-width: 100%; }
.ops-preview .model-meta { margin: .3rem 0 0; }
.ops-item-img { max-width: 320px; max-height: 240px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); }
.model-preview .model-meta { margin: .3rem 0 0; }
.upload-list { list-style: none; margin: .4rem 0 0; padding: 0; }
/* Aligned columns: filename | color | material | remove — consistent across
   many rows so an assembly reads as a table, not a zigzag. */
.upload-list li { color: var(--ok); font-size: .9rem; margin-bottom: .35rem;
  display: grid; grid-template-columns: minmax(0, 1fr) 9rem auto auto;
  gap: .5rem; align-items: center; }
.upload-list li > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list li.no-attrs { grid-template-columns: minmax(0, 1fr) auto; }
.file-attrs { display: contents; }
.file-attrs input, .file-attrs select { padding: .25rem .5rem; font-size: .85rem; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; width: 100%; min-width: 0; }
/* Per-body material is an opinion — visible only while the item's advanced
   section is open (JS mirrors the <details> state onto .adv-open) — and only
   for FFF: multi-material bodies are filament math. */
.item-block:not(.adv-open) .file-attrs select { display: none; }
.item-block:not([data-tech="fff"]) .file-attrs select { display: none; }
/* Per-technology fields: JS marks the chosen process's group .tech-active
   (and disables the others so they never submit). No-JS shows everything. */
.wizard.js .tech-only { display: none; }
.wizard.js .tech-only.tech-active { display: block; }
.upload-list .linklike, .intake-previews .linklike { background: none; border: none; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; padding: 0; text-decoration: underline; }
.item-thumb { width: 44px; height: 44px; object-fit: contain; vertical-align: middle; margin-right: .5rem; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; }
.intake-previews { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: .6rem; }
.intake-thumb { display: flex; flex-direction: column; gap: .25rem; max-width: 140px; }
.intake-thumb img { width: 120px; height: 90px; object-fit: cover; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.intake-file-icon { font-size: 2rem; }
.price-estimate { color: var(--ok); font-weight: 600; white-space: pre-line; }
.wizard.js .no-js-submit { display: none; }
/* Print mode: a file is required — the link path isn't offered. */
.wizard.js[data-mode="easy"] .link-fields { display: none; }
.easy-req { display: none; }
.wizard.js[data-mode="easy"] .easy-req { display: inline; }
/* Inline step validation */
.step-error { color: var(--danger); font-weight: 600; margin: 1rem 0 0; }
.wizard .invalid { border-color: var(--danger) !important; outline: 2px solid var(--danger); outline-offset: 1px; }
/* Server-error re-render: show the whole form at once so nothing is hidden
   behind steps (values are preserved; items with content become visible). */
.wizard.js.show-all .wizard-step { display: block; }
/* Step-3 title fragments per mode */
.wizard.js[data-mode="consultant"] .s3-order,
.wizard.js[data-mode="highvolume"] .s3-order { display: none; }
.wizard.js[data-mode="consultant"] .s3-intake,
.wizard.js[data-mode="highvolume"] .s3-intake { display: inline; }
.wizard.js[data-mode="consultant"] .s3-consultant,
.wizard.js[data-mode="highvolume"] .s3-highvolume { display: inline; }

/* Footer */
.env-badge { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: .05rem .5rem; margin-left: .5rem; text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
/* Role badges (per-order role — an operator ordering for themselves is that
   order's CUSTOMER). Colors: customer blue, operator green, support amber,
   admin red. */
.role-customer { color: var(--accent); border-color: var(--accent); }
.role-operator { color: var(--ok); border-color: var(--ok); }
.role-support { color: #e8b446; border-color: #e8b446; }
.role-admin { color: var(--danger); border-color: var(--danger); }

/* Items table: the Details cell is the "start having opinions" affordance. */
#items-table td.item-details-cell { cursor: pointer; }
#items-table td.item-details-cell:hover { color: var(--text); text-decoration: underline dotted; }

/* Federated sign-in buttons (login page + account connections) */
.sso-btn { display: inline-flex; align-items: center; gap: .55rem; }
.sso-btn[disabled] { opacity: .45; cursor: not-allowed; }
.sso-logo { flex: 0 0 auto; }
.sso-divider { display: flex; align-items: center; gap: .6rem; margin: .9rem 0 .6rem; }
.sso-divider::before, .sso-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
