/* ==========================================================================
   Imaginesite·AI — Generator UI
   Visual concept: a drafting table / specification sheet. The wizard steps
   are literally sheets in a spec document, so sheet numbering, hairline
   rules, and corner registration marks are structural, not decorative.
   ========================================================================== */

:root{
  --paper:        #F7F5EE;
  --paper-raised: #FFFFFF;
  --line:         #DAD4C4;
  --line-strong:  #B9B2A0;
  --ink:          #1B2430;
  --ink-soft:     #5B6472;
  --ink-faint:    #8B92A0;
  --blueprint:    #2C5F8A;
  --blueprint-dk: #1E4463;
  --blueprint-tint: #E7EFF5;
  --signal:       #E0A526;
  --signal-dk:    #B7830F;
  --success:      #4B7A5B;
  --danger:       #B5484B;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  --radius: 4px;
  --gap: 20px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--font-body);
  color:var(--ink);
  background:
    linear-gradient(var(--paper), var(--paper)),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(44,95,138,0.035) 27px 28px),
    repeating-linear-gradient(90deg, transparent 0 27px, rgba(44,95,138,0.035) 27px 28px);
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:0.001ms !important; transition-duration:0.001ms !important; }
}

button{ font-family:inherit; }

/* ---------- App shell ---------- */

.app{ max-width:1180px; margin:0 auto; padding:0 24px 48px; }

.app-header{
  display:flex; align-items:baseline; justify-content:space-between;
  padding:28px 4px 18px; border-bottom:2px solid var(--ink);
  flex-wrap:wrap; gap:10px;
}
.brand-cluster{ display:flex; align-items:center; gap:12px; }
.company-logo{ width:38px; height:38px; flex:0 0 auto; border-radius:8px; }
.brand-stack{ display:flex; flex-direction:column; gap:3px; }
.company-name{
  font-family:var(--font-mono); font-size:0.68rem; letter-spacing:0.07em; text-transform:uppercase;
  color:var(--ink-soft);
}
.brand{ font-family:var(--font-display); font-weight:700; font-size:1.3rem; letter-spacing:0.01em; line-height:1; }
.brand-mark{ color:var(--ink); }
.brand-suffix{ color:var(--blueprint); }

.sheet-meta{
  font-family:var(--font-mono); font-size:0.8rem; color:var(--ink-soft);
  display:flex; align-items:center; gap:6px; letter-spacing:0.03em;
}
.sheet-meta-label{ color:var(--ink-faint); }
#sheetNum{ color:var(--blueprint); font-weight:600; }
.sheet-meta-sep{ color:var(--line-strong); }
.sheet-meta-title{
  margin-left:10px; padding-left:10px; border-left:1px solid var(--line-strong);
  color:var(--ink); font-weight:600; text-transform:uppercase; font-size:0.72rem; letter-spacing:0.08em;
}
.advanced-toggle{
  display:flex; align-items:center; gap:10px; font-size:0.76rem; font-weight:600; color:var(--ink-soft);
  cursor:pointer; padding:6px 10px; border:1px solid var(--line); border-radius:99px; background:var(--paper);
}
.advanced-toggle .switch{ width:36px; height:20px; }
.advanced-toggle .switch-track::after{ width:16px; height:16px; }
.advanced-toggle input:checked + .switch-track::after{ transform:translateX(16px); }

.app-body{ display:flex; gap:28px; padding-top:26px; align-items:flex-start; }

/* ---------- Rail (step index) ---------- */

.rail{
  flex:0 0 220px; display:flex; flex-direction:column; gap:2px;
  position:sticky; top:24px;
}
.rail-item{
  display:flex; align-items:baseline; gap:10px; padding:9px 10px;
  border-radius:var(--radius); cursor:pointer; border:1px solid transparent;
  font-size:0.86rem; color:var(--ink-faint); text-align:left; background:none;
}
.rail-item:hover{ background:var(--blueprint-tint); color:var(--ink); }
.rail-item .rn{ font-family:var(--font-mono); font-size:0.72rem; color:inherit; min-width:20px; }
.rail-item.is-current{
  background:var(--paper-raised); border-color:var(--line); color:var(--ink);
  font-weight:600; box-shadow:2px 2px 0 rgba(27,36,48,0.05);
}
.rail-item.is-current .rn{ color:var(--blueprint); }
.rail-item.is-done .rn::after{ content:"✓"; margin-left:4px; color:var(--success); }
.rail-item.is-disabled{ color:var(--line-strong); cursor:default; }
.rail-item:focus-visible, .btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible{
  outline:2px solid var(--blueprint); outline-offset:2px;
}

/* ---------- Sheet (main panel) ---------- */

.stage{ flex:1; min-width:0; }

.sheet{
  position:relative; background:var(--paper-raised);
  border:1px solid var(--line); border-radius:2px;
  padding:36px 40px; min-height:420px;
  box-shadow:4px 4px 0 rgba(27,36,48,0.04);
}
.reg{ position:absolute; width:16px; height:16px; }
.reg::before, .reg::after{ content:""; position:absolute; background:var(--blueprint); opacity:0.5; }
.reg::before{ width:100%; height:1px; top:50%; }
.reg::after{ height:100%; width:1px; left:50%; }
.reg-tl{ top:-8px; left:-8px; }
.reg-tr{ top:-8px; right:-8px; }
.reg-bl{ bottom:-8px; left:-8px; }
.reg-br{ bottom:-8px; right:-8px; }

.step-eyebrow{
  font-family:var(--font-mono); font-size:0.72rem; letter-spacing:0.1em; text-transform:uppercase;
  color:var(--blueprint); margin:0 0 6px;
}
.step-title{ font-family:var(--font-display); font-size:1.7rem; margin:0 0 6px; }
.step-desc{ color:var(--ink-soft); margin:0 0 28px; max-width:60ch; line-height:1.5; }

.field-grid{ display:grid; grid-template-columns:1fr 1fr; gap:20px 24px; }
.field-grid.single{ grid-template-columns:1fr; }
.field{ display:flex; flex-direction:column; gap:6px; }
.field.span-2{ grid-column:1 / -1; }

label{ font-size:0.78rem; font-weight:600; color:var(--ink-soft); letter-spacing:0.01em; }
.label-optional{ font-weight:400; color:var(--ink-faint); text-transform:none; }
.hint{ font-size:0.76rem; color:var(--ink-faint); margin-top:2px; }

input[type="text"], input[type="email"], input[type="url"], input[type="tel"],
input[type="number"], textarea, select{
  font-family:var(--font-body); font-size:0.92rem; color:var(--ink);
  border:1px solid var(--line-strong); border-radius:var(--radius);
  padding:9px 11px; background:var(--paper-raised); width:100%;
}
textarea{ resize:vertical; min-height:88px; line-height:1.5; }
input::placeholder, textarea::placeholder{ color:var(--ink-faint); }

/* ---------- Buttons ---------- */

.btn{
  border-radius:var(--radius); border:1px solid var(--ink); padding:10px 20px;
  font-weight:600; font-size:0.88rem; cursor:pointer; background:var(--paper-raised); color:var(--ink);
}
.btn-primary{ background:var(--blueprint); border-color:var(--blueprint-dk); color:#fff; }
.btn-primary:hover{ background:var(--blueprint-dk); }
.btn-ghost{ border-color:var(--line-strong); color:var(--ink-soft); }
.btn-ghost:hover{ border-color:var(--ink); color:var(--ink); }
.btn-signal{ background:var(--signal); border-color:var(--signal-dk); color:var(--ink); }
.btn-signal:hover{ background:var(--signal-dk); color:#fff; }
.btn-small{ padding:6px 12px; font-size:0.78rem; }
.btn-danger-text{ background:none; border:none; color:var(--danger); font-weight:600; font-size:0.78rem; cursor:pointer; padding:4px; }
.btn:disabled{ opacity:0.4; cursor:not-allowed; }

/* ---------- Choice cards (design step) ---------- */

.choice-row{ display:flex; gap:16px; flex-wrap:wrap; margin-bottom:28px; }
.choice-card{
  flex:1; min-width:220px; border:1.5px solid var(--line-strong); border-radius:var(--radius);
  padding:18px; cursor:pointer; background:var(--paper-raised); text-align:left;
}
.choice-card:hover{ border-color:var(--blueprint); }
.choice-card.is-selected{ border-color:var(--blueprint); background:var(--blueprint-tint); box-shadow:2px 2px 0 rgba(44,95,138,0.15); }
.choice-card h3{ font-family:var(--font-display); font-size:1.05rem; margin:0 0 6px; }
.choice-card p{ margin:0; font-size:0.82rem; color:var(--ink-soft); line-height:1.5; }
.choice-swatch{ display:flex; gap:4px; margin-top:12px; }
.choice-swatch span{ width:20px; height:20px; border-radius:3px; border:1px solid rgba(0,0,0,0.1); }

/* ---------- Colour pickers ---------- */

.colour-row{
  display:flex; align-items:center; gap:12px; padding:12px 14px;
  border:1px solid var(--line); border-radius:var(--radius); margin-bottom:10px; background:var(--paper);
}
.colour-row label{ flex:0 0 150px; }
.colour-row input[type="color"]{
  width:40px; height:40px; border:1px solid var(--line-strong); border-radius:var(--radius);
  padding:2px; background:var(--paper-raised); cursor:pointer;
}
.colour-row input[type="text"]{ width:110px; font-family:var(--font-mono); text-transform:uppercase; }
.colour-row .colour-desc{ color:var(--ink-faint); font-size:0.78rem; flex:1; }

/* ---------- Toggle switch ---------- */

.section-toggle{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:14px 16px; border:1px solid var(--line); border-radius:var(--radius);
  background:var(--paper); margin-bottom:22px;
}
.section-toggle-label{ font-weight:600; font-size:0.9rem; }
.section-toggle-desc{ font-size:0.78rem; color:var(--ink-faint); margin-top:2px; }
.switch{ position:relative; width:44px; height:24px; flex:0 0 auto; }
.switch input{ opacity:0; width:100%; height:100%; position:absolute; margin:0; cursor:pointer; }
.switch-track{
  position:absolute; inset:0; background:var(--line-strong); border-radius:99px; transition:background .15s;
}
.switch-track::after{
  content:""; position:absolute; top:2px; left:2px; width:20px; height:20px; border-radius:50%;
  background:#fff; transition:transform .15s;
}
.switch input:checked + .switch-track{ background:var(--success); }
.switch input:checked + .switch-track::after{ transform:translateX(20px); }
.switch input:focus-visible + .switch-track{ outline:2px solid var(--blueprint); outline-offset:2px; }

.section-body.is-collapsed{ display:none; }

/* ---------- Repeatable items ---------- */

.repeat-item{
  border:1px solid var(--line); border-radius:var(--radius); padding:18px; margin-bottom:16px; background:var(--paper);
  position:relative;
}
.repeat-item-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
.repeat-item-tag{ font-family:var(--font-mono); font-size:0.72rem; color:var(--blueprint); text-transform:uppercase; letter-spacing:0.06em; }
.add-item-btn{ margin-top:4px; }

/* ---------- Image upload field ---------- */

.upload-field{
  border:1.5px dashed var(--line-strong); border-radius:var(--radius); padding:14px;
  display:flex; align-items:center; gap:12px; background:var(--paper);
}
.upload-field.has-file{ border-style:solid; border-color:var(--blueprint); }
.upload-thumb{
  width:52px; height:52px; border-radius:3px; object-fit:cover; background:var(--line);
  flex:0 0 auto; border:1px solid var(--line-strong);
}
.upload-thumb.placeholder{ display:flex; align-items:center; justify-content:center; font-size:0.65rem; color:var(--ink-faint); text-align:center; }
.upload-info{ flex:1; min-width:0; }
.upload-filename{ font-size:0.82rem; font-weight:600; word-break:break-all; }
.upload-meta{ font-size:0.74rem; color:var(--ink-faint); }
.upload-actions{ display:flex; gap:8px; }
.upload-actions input[type="file"]{ display:none; }
.alt-field{ margin-top:10px; }
.upload-warning{ font-size:0.72rem; color:var(--danger); margin-top:2px; font-weight:600; }
.upload-toggles{ display:flex; gap:16px; margin-top:10px; flex-wrap:wrap; }
.upload-toggles label{ display:flex; align-items:center; gap:6px; font-size:0.76rem; font-weight:500; color:var(--ink-soft); cursor:pointer; }
.upload-toggles input{ cursor:pointer; }

/* ---------- Review screen ---------- */

.review-section{
  display:flex; justify-content:space-between; align-items:flex-start; gap:16px;
  padding:14px 0; border-bottom:1px solid var(--line);
}
.review-section:last-child{ border-bottom:none; }
.review-section-name{ font-family:var(--font-mono); font-size:0.72rem; text-transform:uppercase; letter-spacing:0.06em; color:var(--ink-faint); margin-bottom:4px; }
.review-section-value{ font-size:0.92rem; line-height:1.5; }
.review-section-value .muted{ color:var(--ink-faint); font-style:italic; }

/* ---------- Prompt preview ---------- */

.prompt-preview{
  background:var(--ink); color:#D8E4EE; font-family:var(--font-mono); font-size:0.78rem; line-height:1.6;
  border-radius:var(--radius); padding:20px; max-height:340px; overflow-y:auto; white-space:pre-wrap;
  margin-bottom:20px;
}
.generate-actions{ display:flex; gap:12px; flex-wrap:wrap; margin-bottom:8px; }
.generate-note{ font-size:0.8rem; color:var(--ink-soft); margin-top:14px; line-height:1.6; }

/* ---------- Stage nav / progress ---------- */

.stage-nav{ display:flex; align-items:center; gap:18px; margin-top:20px; }
.progress-track{ flex:1; height:6px; background:var(--line); border-radius:99px; overflow:hidden; }
.progress-fill{ height:100%; background:var(--blueprint); border-radius:99px; transition:width .2s; }
.stage-note{ min-height:20px; font-size:0.8rem; color:var(--danger); margin-top:10px; }

/* ---------- Footer ---------- */

.app-footer{
  margin-top:36px; padding:16px 4px 8px; border-top:1px solid var(--line);
  text-align:center; color:var(--ink-faint); font-size:0.7rem; line-height:1.6;
}
.app-footer p{ margin:0 0 4px; }
.app-footer p:last-child{ margin-bottom:0; }

/* ---------- Review layout (spec + checklist / live preview) ---------- */

.review-layout{ display:grid; grid-template-columns:1fr 1fr; gap:32px; align-items:start; }
.review-col{ min-width:0; }
.review-subheading{ font-family:var(--font-display); font-size:1rem; margin:24px 0 12px; }

.a11y-checklist{ display:flex; flex-direction:column; gap:2px; }
.a11y-item{ display:flex; gap:10px; padding:9px 4px; border-bottom:1px solid var(--line); align-items:flex-start; }
.a11y-item:last-child{ border-bottom:none; }
.a11y-icon{ flex:0 0 auto; font-weight:700; width:18px; text-align:center; }
.a11y-pass .a11y-icon{ color:var(--success); }
.a11y-warn .a11y-icon{ color:var(--signal-dk); }
.a11y-label{ font-weight:600; font-size:0.84rem; }
.a11y-detail{ font-size:0.76rem; color:var(--ink-faint); margin-top:2px; line-height:1.5; }

.preview-toolbar{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.preview-toolbar-label{ font-family:var(--font-mono); font-size:0.72rem; text-transform:uppercase; letter-spacing:0.06em; color:var(--ink-faint); }
.device-toggle{ display:flex; border:1px solid var(--line-strong); border-radius:var(--radius); overflow:hidden; }
.device-btn{ border:none; background:var(--paper-raised); color:var(--ink-soft); font-size:0.76rem; font-weight:600; padding:6px 14px; cursor:pointer; }
.device-btn.is-active{ background:var(--blueprint); color:#fff; }

.preview-frame-wrap{ border:1px solid var(--line-strong); border-radius:var(--radius); overflow:hidden; background:var(--paper); }
.preview-frame{ width:100%; border:none; display:block; background:#fff; }
.preview-frame-desktop .preview-frame{ height:480px; }
.preview-frame-mobile{ max-width:340px; margin:0 auto; }
.preview-frame-mobile .preview-frame{ height:560px; }

@media (max-width: 900px){
  .review-layout{ grid-template-columns:1fr; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px){
  .app-body{ flex-direction:column; }
  .rail{ position:static; flex-direction:row; flex-wrap:wrap; width:100%; }
  .rail-item{ flex:0 0 auto; }
  .field-grid{ grid-template-columns:1fr; }
  .sheet{ padding:24px 20px; }
  .colour-row label{ flex-basis:120px; }
}
