/* Scanory Studio. The Scanory palette and type: ivory, ink, bronze; Newsreader and Instrument Sans. */
:root {
  --paper: #f2ebdd;
  --paper-2: #e5dfd4;   /* Warm Plaster */
  --walnut: #342820;    /* Dark Walnut */
  --stone: #88776a;     /* Muted Stone: borders and marks only; too light for small text */
  --ink: #211a17;
  --ink-2: #5b4d43;
  --bronze: #a88759;
  --bronze-deep: #6e5736; /* 5.4:1 on the plaster panels (was 4.2:1 at #7d6440) */
  --line: rgb(33 26 23 / 0.16);
  --error: #9b2c1f;
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'Instrument Sans', system-ui, sans-serif;
  --gutter: max(1.25rem, env(safe-area-inset-left));
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 1rem/1.55 var(--sans); color: var(--ink); background: var(--paper); }
h1, h2, h3 { font-family: var(--serif); font-weight: 300; letter-spacing: -0.01em; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--gutter); top: -4rem; background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; z-index: 20; }
.skip:focus { top: 0.5rem; }
[hidden] { display: none !important; }

.eyebrow { margin: 0; font: 500 0.6875rem/1.4 var(--sans); letter-spacing: 0.18em; text-transform: uppercase; color: var(--bronze-deep); }
.lede { color: var(--ink-2); max-width: 60ch; }

/* Header */
.bar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: auto 1fr auto; gap: 0.25rem 1rem; align-items: center;
  padding: 0.85rem var(--gutter); background: rgb(242 235 221 / 0.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.mark { margin: 0; font: 400 1.05rem/1 var(--serif); letter-spacing: 0.28em; }
.bar-product { margin: 0; font-size: 0.8125rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save { margin: 0; font-size: 0.75rem; color: var(--ink-2); text-align: right; min-width: 0; overflow-wrap: anywhere; } /* long status text wraps at large text sizes */
.save[data-kind='error'] { color: var(--error); }
.save[data-kind='saving']::before, .save[data-kind='dirty']::before { content: ''; display: inline-block; width: 0.4rem; height: 0.4rem; margin-right: 0.4rem; border-radius: 50%; background: var(--bronze); vertical-align: 0.1em; }
@media (max-width: 599px) { .bar { grid-template-columns: auto 1fr; } .bar-product { display: none; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 2.75rem; padding: 0.7rem 1.4rem;
  font: 500 0.6875rem/1.2 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; text-decoration: none;
  color: var(--ink); background: var(--bronze); border: 1px solid var(--bronze); border-radius: 0; cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease); }
.btn:hover { background: transparent; }
.btn-quiet { background: transparent; border-color: var(--line); }
.btn-quiet:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link { padding: 0; border: 0; background: none; color: var(--ink); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; text-align: left; }
.icon { width: 2.75rem; height: 2.75rem; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 1rem; }
.icon:disabled { opacity: 0.3; cursor: default; }

/* Gate pages */
.gate, .studio-gate .gate { max-width: 36rem; margin: 0 auto; padding: 18vh var(--gutter) 4rem; }
.gate h1 { font-size: clamp(2rem, 1.4rem + 3vw, 3rem); line-height: 1.05; margin: 0.75rem 0 1rem; }
.gate-mark { font: 400 1.05rem/1 var(--serif); letter-spacing: 0.28em; margin: 0 0 2rem; }
.gate form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.gate label { font-size: 0.8125rem; }
.gate input[type=email], .gate input[type=text] { width: 100%; }

/* Layout: editor and preview */
.studio { display: grid; grid-template-columns: minmax(0, 1fr); }
.editor { padding: 1.5rem var(--gutter) 6rem; outline: none; }
.preview { display: none; }
.preview-toggle { position: fixed; z-index: 9; right: var(--gutter); bottom: max(1rem, env(safe-area-inset-bottom)); min-height: 3rem; padding: 0 1.4rem;
  font: 500 0.6875rem/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--paper); background: var(--ink); border: 0; box-shadow: 0 0.5rem 1.5rem rgb(33 26 23 / 0.25); cursor: pointer; }
body.show-preview { overflow: hidden; }
body.show-preview .preview { display: grid; position: fixed; inset: 0; z-index: 30; background: #0f0806; grid-template-rows: auto 1fr; }
body.show-preview .preview-toggle { display: none; }
/* The frame stays loaded while hidden, so opening the preview never reloads it. */
.preview iframe { width: 100%; height: 100%; border: 0; background: #0f0806; }
.studio > .preview { display: grid; grid-template-rows: auto 1fr; visibility: hidden; position: fixed; inset: 0; z-index: -1; }
body.show-preview .studio > .preview { visibility: visible; z-index: 30; }
.preview-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; padding: 0.75rem var(--gutter); color: var(--paper); background: var(--walnut); }
.preview-head .eyebrow { color: var(--bronze); }
.preview-note { margin: 0; font-size: 0.75rem; color: rgb(242 235 221 / 0.7); flex: 1 1 14rem; }
.preview-close { color: var(--paper); border-color: rgb(242 235 221 / 0.3); }

@media (min-width: 1024px) {
  .studio { grid-template-columns: minmax(24rem, 34rem) minmax(0, 1fr); min-height: calc(100vh - 3.4rem); }
  .editor { padding: 2rem 2.5rem 4rem; border-right: 1px solid var(--line); }
  .studio > .preview { visibility: visible; position: sticky; top: 3.4rem; z-index: auto; height: calc(100vh - 3.4rem); }
  .preview-close, .preview-toggle { display: none; }
}

/* Steps */
.steps ol { display: flex; gap: 0.25rem; margin: 0 calc(-1 * var(--gutter)) 1.5rem; padding: 0 var(--gutter) 0.25rem; list-style: none; overflow-x: auto; scrollbar-width: none; }
.steps button { min-height: 2.75rem; padding: 0.5rem 0.75rem; border: 0; border-bottom: 1px solid var(--line); background: none; white-space: nowrap; font-size: 0.8125rem; color: var(--ink-2); cursor: pointer; }
.steps button[aria-current='step'] { color: var(--ink); border-bottom: 2px solid var(--bronze); }
@media (min-width: 1024px) { .steps ol { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; } }
.step-title { font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem); line-height: 1.05; margin: 0.5rem 0 0.5rem; outline: none; }
.notice { margin: 0 0 1.5rem; padding: 0.9rem 1rem; border-left: 2px solid var(--bronze); background: var(--paper-2); font-size: 0.875rem; }
.step-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; }
.step-nav .btn:only-child, #next:first-child { margin-left: auto; }

/* Scenes and fields */
.scene { margin: 2rem 0 0; padding: 1.5rem 0 0; border: 0; border-top: 1px solid var(--line); min-width: 0; }
.scene-plain { border-top: 0; padding-top: 0.5rem; }
.scene legend { padding: 0; float: left; width: 100%; }
.scene legend + * { clear: both; }
.scene-name { font: 300 1.5rem/1.2 var(--serif); }
.scene-top { display: grid; gap: 0.75rem; margin: 0.4rem 0 1.25rem; }
.scene-about { margin: 0; font-size: 0.875rem; color: var(--ink-2); }
.switch-row { display: flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; }
.switch { appearance: none; position: relative; width: 2.6rem; height: 1.5rem; margin: 0; border: 1px solid var(--stone); border-radius: 1rem; background: transparent; cursor: pointer; flex: none; }
.switch::after { content: ''; position: absolute; top: 0.2rem; left: 0.2rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--ink-2); transition: transform 0.2s var(--ease); }
.switch:checked { background: var(--bronze); border-color: var(--bronze); }
.switch:checked::after { transform: translateX(1.1rem); background: var(--ink); }
.field { display: grid; gap: 0.35rem; margin: 0 0 1.25rem; min-width: 0; }
.field > label, .label { margin: 0; font-size: 0.8125rem; font-weight: 500; }
.optional { font-weight: 400; color: var(--ink-2); }
.hint { font-size: 0.75rem; color: var(--ink-2); }
input[type=text], input[type=email], input[type=date], input[type=datetime-local], textarea {
  width: 100%; min-height: 2.9rem; padding: 0.7rem 0.8rem; background: #fbf8f1; border: 1px solid var(--line); border-radius: 0; font-size: 1rem; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 1px var(--ink); }
input.narrow { max-width: 5rem; }
[aria-invalid='true'] { border-color: var(--error) !important; }
.field-date input { max-width: 16rem; }
.field-foot { display: flex; justify-content: space-between; gap: 1rem; min-height: 1rem; }
.count { margin-left: auto; font-size: 0.6875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.count.over { color: var(--error); font-weight: 500; }
.error { font-size: 0.75rem; color: var(--error); }
.field-check { grid-template-columns: auto 1fr; align-items: start; gap: 0.6rem; font-size: 0.875rem; }
.field-check input { width: 1.25rem; height: 1.25rem; margin: 0.15rem 0 0; accent-color: var(--bronze-deep); }
.field-check label { font-weight: 400; }

/* Photographs */
.image-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.thumb { width: 6.5rem; aspect-ratio: 4 / 5; background: var(--paper-2) center / cover no-repeat; border: 1px solid var(--line); }
.thumb.empty { background-image: linear-gradient(135deg, transparent 49.5%, var(--line) 50%, transparent 50.5%); }
.image-actions { display: grid; gap: 0.5rem; }
.progress { height: 2px; background: var(--line); }
.progress span { display: block; height: 100%; width: 0; background: var(--bronze); transition: width 0.2s linear; }

/* Lists */
.list-head { display: flex; align-items: baseline; justify-content: space-between; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.item { padding: 1rem; background: rgb(255 255 255 / 0.35); border: 1px solid var(--line); }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.item-title { margin: 0; font: 300 1.125rem/1.2 var(--serif); outline: none; }
.item-tools { display: flex; gap: 0.25rem; }

/* Review */
.review { margin-top: 1.5rem; display: grid; gap: 1rem; justify-items: start; }
.issues { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.5rem; font-size: 0.875rem; }

dialog { max-width: 30rem; padding: 1.75rem; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgb(33 26 23 / 0.5); }
dialog h2 { margin-top: 0; font-size: 1.6rem; line-height: 1.15; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

form.readonly input, form.readonly textarea { background: transparent; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

.privacy, .privacy-line { margin: 0; font-size: 0.75rem; color: var(--ink-2); }
.privacy-line { margin: -0.75rem 0 1.25rem; }
.thumb.missing { background-image: none; border-style: dashed; border-color: var(--stone); }
/* The file input itself is visually hidden; its visible button shows the keyboard focus. */
.field-image:has(input[type=file]:focus-visible) label.btn { outline: 2px solid var(--ink); outline-offset: 3px; }

/* 2026-10-29 journey fixes (J-1..J-6, docs/STUDIO-CUSTOMER-FINDINGS-2026-10-29.md) */
/* J-4: what the whole task is, first step only */
.how { margin: 0 0 1.75rem; padding: 0.9rem 1rem 0.9rem 2rem; background: var(--paper-2); font-size: 0.875rem; display: grid; gap: 0.3rem; }
/* J-5: optional fields behind one disclosure per scene */
details.more { margin-top: 0.5rem; border-top: 1px solid var(--line); }
details.more > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-size: 0.875rem; color: var(--ink-2); list-style-position: inside; }
details.more[open] > summary { margin-bottom: 0.75rem; }
/* J-6: one bottom bar with Back, Preview and Next; always reachable, never on top of a field */
.preview-toggle { display: none; }
.nav-preview { display: inline-flex; }
@media (max-width: 1023px) {
  .editor { padding-bottom: 2rem; }
  .step-nav { position: sticky; bottom: 0; z-index: 8; margin: 2rem calc(-1 * var(--gutter)) 0; padding: 0.75rem var(--gutter) max(0.75rem, env(safe-area-inset-bottom));
    background: rgb(242 235 221 / 0.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); gap: 0.5rem; }
  .step-nav .btn { min-height: 44px; padding-inline: 1rem; }
  .step-nav #next { margin-left: auto; }
}
@media (min-width: 1024px) { .nav-preview { display: none; } }
.switch { min-width: 44px; min-height: 26px; }
.switch-row { min-height: 44px; display: flex; align-items: center; gap: 0.6rem; }
/* J-2: summary before sending */
.summary { margin: 0; width: 100%; display: grid; gap: 0.5rem; padding: 1rem; background: var(--paper-2); font-size: 0.875rem; }
.sum-row { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.5rem; align-items: start; }
.sum-row dt { color: var(--ink-2); } .sum-row dd { margin: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 0.4rem 0.75rem; align-items: center; }
.thumbs { display: inline-flex; gap: 0.3rem; vertical-align: middle; } .thumbs img { width: 40px; height: 40px; object-fit: cover; border: 1px solid var(--line); }
@media (max-width: 399px) { .sum-row { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; } }
.final-note { margin: 0; padding: 0.75rem 1rem; border-left: 2px solid var(--bronze); font-size: 0.875rem; }
/* corrections after sending */
.correction { display: grid; gap: 0.75rem; width: 100%; justify-items: start; }
.correction textarea { width: 100%; }
.correction blockquote { margin: 0; padding: 0.6rem 0.9rem; border-left: 2px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.875rem; }
.notice-session { border-left-color: #8a2b1d; display: grid; gap: 0.4rem; } .notice-session p { margin: 0; }
#send-confirm p { max-width: 34rem; }
/* contrast: the small label on the dark preview panel (bronze on #342820 was 4.3:1) */
.preview .eyebrow, .preview-head .eyebrow { color: #cdb184; }
/* large text on a narrow phone: the bottom bar wraps instead of pushing "Next" off the screen */
@media (max-width: 1023px) { .step-nav { flex-wrap: wrap; } .step-nav .btn { flex: 1 1 auto; min-width: 0; } .step-nav #next { margin-left: 0; } }
