/* ============================================================
   ARCHI-CODE — visual system
   Concept: an architectural drawing set. Paper, ink, a blueprint
   accent, dimension-line progress bars, title-block cards.
   ============================================================ */

:root{
  --ink:        #17221D;
  --ink-soft:   #45524A;
  --paper:      #EEEAE0;
  --paper-raise:#F7F4EC;
  --line:       #C9C0AA;
  --line-soft:  #DAD3C0;
  --blueprint:  #1B4965;
  --blueprint-deep: #0E2C3E;
  --blueprint-tint: #DCE7EC;
  --accent:     #C1440E;
  --accent-tint:#F3DCCB;
  --success:    #2F6E4F;
  --success-tint:#DCEADF;

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

  --radius: 3px;
  --container: 920px;
}

html[lang="fa"]{
  --font-display: 'Vazirmatn', sans-serif;
  --font-body: 'Vazirmatn', sans-serif;
}

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
  min-height: 100vh;
}
@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

img,svg{ max-width:100%; display:block; }
button{ font-family: inherit; }
a{ color: var(--blueprint); }

h1,h2,h3,h4{ font-family: var(--font-display); margin: 0 0 .4em; font-weight: 600; letter-spacing: -0.01em; }

.container{ max-width: var(--container); margin: 0 auto; padding: 0 20px; position:relative; z-index:3; }

/* ---------- Top bar ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 18px 20px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-raise);
}
.topbar .brand{ display:flex; align-items:baseline; gap:10px; }
.topbar .brand .mark{
  font-family: var(--font-mono); font-weight:700; font-size: 13px;
  color: var(--paper-raise); background: var(--blueprint);
  padding: 3px 7px; border-radius: 2px; letter-spacing: .06em;
}
.topbar .brand .name{ font-family: var(--font-display); font-weight:700; font-size: 18px; letter-spacing: .02em; }
.topbar .brand .sub{ font-size: 12px; color: var(--ink-soft); display:none; }
@media (min-width:640px){ .topbar .brand .sub{ display:inline; } }

.lang-btn{
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  padding: 7px 14px; border-radius: var(--radius); cursor:pointer;
  font-size: 13px; font-weight: 600; font-family: var(--font-mono);
}
.lang-btn:hover{ background: var(--ink); color: var(--paper-raise); }
.lang-btn:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--blueprint); outline-offset: 2px;
}

/* ---------- Crop marks (signature motif) ---------- */
.crop{ position:relative; }
.crop::before, .crop::after,
.crop .cm-tl, .crop .cm-tr, .crop .cm-bl, .crop .cm-br{ content:""; position:absolute; width:14px; height:14px; pointer-events:none; }
.crop::before{ top:-1px; left:-1px; border-top:2px solid var(--ink); border-left:2px solid var(--ink); }
.crop::after{ bottom:-1px; right:-1px; border-bottom:2px solid var(--ink); border-right:2px solid var(--ink); }

/* ---------- Home / hero ---------- */
/* Full-height silhouette image anchored to the left edge, aspect-ratio
   preserved (no cropping). Sits on top of the site's normal grid+paper
   background; the transparent PNG lets that grid show through around it. */
.home-bg-face{
  position: fixed; left:50%; top:0;
  transform: translateX(-50%);
  height: 100vh;
  /* Explicit stretched width (native aspect 910:720, x1.2 horizontally) instead of a
     CSS `transform: scaleX()` — this is a real layout dimension, so getBoundingClientRect()
     (which the mesh-overlay JS reads every draw) reports it directly with no transform-math
     ambiguity, keeping the mesh precisely aligned to the image at any viewport size. */
  width: calc(100vh * 1.51667);
  object-fit: fill;
  z-index: 0;
  pointer-events: none;
  display:block;
}
/* Reverted: grid pattern goes back to being only the body's own background
   (naturally behind the fixed hero image), not a separate layer in front. */
.home-bg-grid{
  display: none;
}
/* Fades the image out into solid paper before it reaches the text/card
   column. Much lighter than before, especially on the left (over the
   face/mesh), so the image itself stays clearly visible there. */
.home-bg-scrim{
  position: fixed; inset:0;
  background: linear-gradient(90deg, transparent 0%, transparent 38%, rgba(238,234,224,.12) 58%, rgba(238,234,224,.45) 72%, var(--paper) 90%);
  z-index: 1;
  pointer-events: none;
}
.home-thread-overlay{
  position: fixed; inset:0; width:100vw; height:100vh;
  pointer-events:none; z-index: 2;
}
/* Colors come from inline SVG gradient/fill attributes set in JS (per-edge
   gradient between each edge's two region colors — the soft fade) — CSS
   here only handles opacity/transition so it doesn't fight those colors. */
.hbd-mesh-line{ opacity:.55; transition: opacity .18s ease, stroke-width .18s ease; }
.hbd-mesh-line.active{ opacity:1; }
.hbd-node{ opacity:.95; transition: opacity .18s ease; }
.hbd-node-dim{ opacity:.5; }
.hbd-node.active{ opacity:1; }
.home-thread{
  fill:none; stroke-width:1.4px; opacity:.55;
  transition: stroke-width .18s ease, opacity .18s ease;
}
.home-thread.active{ stroke-width:2.6px; opacity:1; }

.topbar{ position:relative; z-index:5; }
.site-footer{ position:relative; z-index:5; }

.hero{ padding: 56px 0 28px; }
.kicker{
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing:.12em;
  font-size: 12px; color: var(--blueprint); margin-bottom: 14px; display:flex; align-items:center; gap:8px;
}
.kicker::before{ content:""; width: 22px; height: 1.5px; background: var(--blueprint); display:inline-block; }
.hero h1{
  font-size: clamp(28px, 4vw, 42px); max-width: 18ch;
  /* Sits directly over the background photo, whose tone varies a lot from spot to spot —
     a plain dark ink color can read fine in one area and nearly vanish in another. This
     halo (several stacked light text-shadows) keeps the text legible everywhere without
     changing its actual color or adding a visible box/panel behind it. */
  text-shadow: 0 0 4px var(--paper), 0 0 10px var(--paper), 0 0 18px var(--paper), 0 1px 2px var(--paper);
}
.hero p{
  max-width: 62ch; font-size: 16px; color: #000;
  /* Same halo technique as .hero h1 just above, instead of the old white-to-black
     gradient-text effect — solid black reads more consistently than a gradient did once
     the text wraps across multiple lines over the photo. */
  text-shadow: 0 0 4px var(--paper), 0 0 10px var(--paper), 0 0 18px var(--paper), 0 1px 2px var(--paper);
}

.id-box{
  margin-top: 26px; background: var(--paper-raise); border: 1.5px solid var(--ink);
  padding: 16px 18px; border-radius: var(--radius); display:flex; align-items:center; gap:16px; flex-wrap:wrap;
}
.id-box .id-label{ font-size: 12px; color: var(--ink-soft); text-transform:uppercase; letter-spacing:.08em; }
.id-box .id-value{ font-family: var(--font-mono); font-size: 18px; font-weight:700; letter-spacing:.04em; }
.id-box .id-hint{ font-size: 12.5px; color: var(--ink-soft); flex: 1 1 220px; }
.id-box input[type=text]{
  font-family: var(--font-mono); border:1px solid var(--ink); border-radius:var(--radius);
  padding:6px 8px; background: var(--paper); color:var(--ink); font-size: 14px; width: 160px;
}
.id-box button{ border:1px solid var(--ink); background:var(--ink); color: var(--paper-raise); padding:6px 12px; border-radius: var(--radius); cursor:pointer; font-size:13px; }

/* ---------- Sheet cards (title-block style) ---------- */
.sheet-grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 30px 0 60px; }
@media (max-width: 860px){ .sheet-grid{ grid-template-columns: 1fr; } }

.sheet-card{
  background: var(--paper-raise); border: 1.5px solid var(--ink); border-radius: var(--radius);
  display:flex; flex-direction:column; overflow:hidden; transition: transform .15s ease, box-shadow .15s ease;
}
.sheet-card:hover{ transform: translateY(-3px); box-shadow: 4px 8px 0 rgba(23,34,29,0.08); }
.sheet-card .sc-head{
  padding: 14px 16px; border-bottom: 1px dashed var(--line);
  display:flex; align-items:center; justify-content: space-between;
}
.sheet-card .sc-num{ font-family: var(--font-mono); font-size:12px; color: var(--blueprint); font-weight:700; letter-spacing:.05em; }
.sheet-card .sc-icon{ width:34px; height:34px; }
.sheet-card .sc-body{ padding: 16px; flex:1; display:flex; flex-direction:column; gap:8px; }
.sheet-card h3{ font-size: 19px; margin-bottom:2px; }
.sheet-card .sc-desc{ font-size: 13.5px; color: var(--ink-soft); flex:1; }

.dim-bar{ height: 14px; position:relative; margin: 4px 0 2px; }
.dim-bar .track{ position:absolute; inset:0; border-top:1px solid var(--ink); border-bottom:1px solid var(--ink); }
.dim-bar .fill{ position:absolute; top:0; bottom:0; left:0; background: var(--blueprint-tint); border-inline-end: 2px solid var(--blueprint); transition: width .3s ease; }
.dim-bar .ticks{ position:absolute; inset:0; display:flex; justify-content:space-between; }
.dim-bar .ticks span{ width:1px; background: var(--ink); opacity:.35; }
.status-row{ display:flex; align-items:center; justify-content:space-between; font-size:12px; font-family: var(--font-mono); color: var(--ink-soft); }
.status-row .status.complete{ color: var(--success); font-weight:700; }
.status-row .status.progress{ color: var(--blueprint); font-weight:700; }

.sc-foot{ padding: 12px 16px; border-top: 1px dashed var(--line); }
.btn{
  display:inline-flex; align-items:center; gap:8px; justify-content:center;
  border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper-raise);
  padding: 10px 16px; border-radius: var(--radius); cursor:pointer; font-size:14px; font-weight:600;
  width:100%; font-family: var(--font-body); text-decoration:none;
}
.btn:hover{ background: var(--blueprint); border-color: var(--blueprint); }
.btn.secondary{ background: transparent; color: var(--ink); }
.btn.secondary:hover{ background: var(--ink); color: var(--paper-raise); }
.btn.ghost{ background: transparent; color: var(--ink-soft); border-color: var(--line); width:auto; }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

/* ---------- Survey shell ---------- */
.survey-header{ padding: 20px 0 8px; }
.survey-title-row{ display:flex; align-items:baseline; gap:12px; flex-wrap:wrap; }
.survey-title-row .code{ font-family: var(--font-mono); color: var(--blueprint); font-weight:700; font-size:13px; }
.progress-wrap{ margin: 14px 0 6px; }
.progress-label{ display:flex; justify-content:space-between; font-size:12.5px; color:var(--ink-soft); font-family: var(--font-mono); margin-bottom:6px; }

.card{
  background: var(--paper-raise); border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 26px 24px; margin: 18px 0; position:relative;
}
.card h2{ font-size: 21px; }
.card .card-intro{ color: var(--ink-soft); font-size: 14.5px; margin-bottom: 18px; }

.field{ margin-bottom: 22px; }
.field label.q{ display:block; font-weight:600; font-size: 15px; margin-bottom: 8px; }
.field .opt-tag{ font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-soft); border:1px solid var(--line); border-radius: 2px; padding:1px 6px; margin-inline-start:8px; text-transform:uppercase; letter-spacing:.05em; }

.field.error label.q{ color: var(--accent); }
.field.error .choices .chip, .field.error .plan-grid .plan-option, .field.error input, .field.error select{ border-color: var(--accent) !important; }
.field.error .rating-scale .rating-num{ border-color: var(--accent) !important; }
.field-error-msg{ color: var(--accent); font-size:12.5px; margin-top:6px; display:none; }
.field.error .field-error-msg{ display:block; }

input[type=text], input[type=number], select{
  width:100%; font-family: var(--font-body); font-size:15px; padding: 10px 12px;
  border: 1.4px solid var(--line); border-radius: var(--radius); background: var(--paper);
  color: var(--ink);
}
input[type=number]{ font-family: var(--font-mono); max-width: 180px; }
select{ appearance:none; background-image: none; cursor:pointer; }
.select-wrap{ position:relative; max-width: 420px; }
.select-wrap::after{
  content:"▾"; position:absolute; inset-inline-end:12px; top:50%; transform:translateY(-50%);
  color: var(--ink-soft); pointer-events:none; font-size:12px;
}
input:focus, select:focus{ border-color: var(--blueprint); }

.choices{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{
  border: 1.4px solid var(--line); border-radius: 999px; padding: 8px 16px; cursor:pointer;
  font-size: 14px; background: var(--paper); user-select:none; transition: all .12s ease;
}
.chip:hover{ border-color: var(--blueprint); }
.chip.selected{ background: var(--blueprint); border-color: var(--blueprint); color: var(--paper-raise); }

/* 1-5 feedback rating scale (Part 4) — a connected number line instead of plain chips,
   with every point labeled so it doesn't look like only the ends matter. */
.rating-scale{ position:relative; display:flex; justify-content:space-between; gap:4px; margin:14px 0 4px; padding:0 2px; }
.rating-scale::before{
  content:''; position:absolute; top:19px; left:23px; right:23px; height:2px;
  background:var(--line); z-index:0;
}
.rating-opt{
  position:relative; z-index:1; display:flex; flex-direction:column; align-items:center;
  gap:8px; cursor:pointer; user-select:none; flex:1;
}
.rating-num{
  width:40px; height:40px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  font-family:var(--font-mono); font-size:15px; font-weight:600; color:var(--ink);
  background:var(--paper); border:1.6px solid var(--line); transition: all .14s ease;
}
.rating-opt:hover .rating-num{ border-color:var(--blueprint); transform:translateY(-1px); }
.rating-opt.selected .rating-num{
  background:var(--blueprint); border-color:var(--blueprint); color:var(--paper-raise); transform:scale(1.08);
}
.rating-label{ font-size:11px; color:var(--ink-soft); text-align:center; line-height:1.3; max-width:72px; }
.rating-opt.selected .rating-label{ color:var(--ink); font-weight:600; }
@media (max-width:420px){
  .rating-num{ width:34px; height:34px; font-size:13.5px; }
  .rating-label{ font-size:10px; max-width:58px; }
  .rating-scale::before{ top:17px; }
}

.ref-diagram{ margin: 10px 0 16px; border: 1.4px solid var(--line); border-radius: var(--radius); overflow:hidden; background: var(--paper); }
.ref-diagram img{ width:100%; display:block; }
.ref-diagram .ref-caption{ font-size:12.5px; color: var(--blueprint); text-align:center; padding:6px 8px; border-top:1px dashed var(--line); font-family: var(--font-mono); }

.plan-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-top: 10px; }
.plan-option{
  border: 1.4px solid var(--line); border-radius: var(--radius); padding: 10px; cursor:pointer; background: var(--paper);
  text-align:center; transition: all .12s ease;
}
.plan-option:hover{ border-color: var(--blueprint); }
.plan-option.selected{ border-color: var(--blueprint); background: var(--blueprint-tint); box-shadow: inset 0 0 0 2px var(--blueprint); }
.plan-option .thumb{ position:relative; width:100%; aspect-ratio: 4/3; background: var(--paper-raise); border:1px solid var(--line); border-radius:2px; margin-bottom:8px; overflow:hidden; }
.plan-option .thumb img, .plan-option .thumb svg{ width:100%; height:100%; object-fit:contain; }

.thumb-zoom-btn{
  position:absolute; top:5px; inset-inline-end:5px; width:26px; height:26px; padding:0;
  display:flex; align-items:center; justify-content:center;
  background: rgba(247,244,236,0.9); border:1px solid var(--line); border-radius:50%;
  color: var(--ink); cursor:pointer;
}
.thumb-zoom-btn svg{ width:14px; height:14px; }
.thumb-zoom-btn:hover{ background: var(--paper-raise); border-color: var(--blueprint); color: var(--blueprint); }

.lightbox-overlay{
  position:fixed; inset:0; background: rgba(20,20,20,0.85); z-index:999;
  display:flex; align-items:center; justify-content:center; padding:5vh 5vw;
}
.lightbox-inner{ position:relative; max-width:90vw; max-height:90vh; text-align:center; }
.lightbox-inner img{ max-width:90vw; max-height:80vh; border-radius:3px; background:#fff; display:block; margin:0 auto; }
.lightbox-caption{ color:#fff; font-size:14px; margin-top:12px; }
.lightbox-close{
  position:absolute; top:-14px; inset-inline-end:-14px; width:32px; height:32px; border-radius:50%;
  background:#fff; border:none; font-size:20px; line-height:1; cursor:pointer; color:var(--ink);
}
.plan-option .cap{ font-size: 13px; font-weight:600; }

.palette-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 14px; margin-top: 10px; }
.palette-option{
  border: 1.4px solid var(--line); border-radius: var(--radius); padding: 10px; cursor:pointer; background: var(--paper);
  text-align:center; transition: all .12s ease;
}
.palette-option:hover{ border-color: var(--blueprint); }
.palette-option.selected{ border-color: var(--blueprint); background: var(--blueprint-tint); box-shadow: inset 0 0 0 2px var(--blueprint); }
.palette-strip{ display:flex; width:100%; height:36px; border:1px solid var(--line); border-radius:2px; overflow:hidden; margin-bottom:8px; }
.palette-swatch{ flex:1; }
.palette-option .cap{ font-size: 13px; font-weight:600; }

.group-title{ font-family: var(--font-mono); font-size:11.5px; text-transform:uppercase; letter-spacing:.08em; color: var(--blueprint); margin: 26px 0 4px; padding-top:14px; border-top:1px dashed var(--line); }
.group-title:first-child{ border-top:none; padding-top:0; margin-top:0; }
.group-note{ font-size: 13.5px; color: var(--ink-soft); margin-bottom: 14px; }

.total-row{ display:flex; gap:20px; align-items:baseline; font-family: var(--font-mono); font-size: 14px; margin-top: 6px; flex-wrap:wrap; }
.total-row .val{ font-weight:700; font-size:16px; }
.total-row .val.over{ color: var(--accent); }
.total-row .val.ok{ color: var(--success); }

.areas-layout{ display:block; }
.areas-col-right{ margin-top: 8px; }
@media (min-width: 860px){
  .areas-layout{ display:grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items:start; }
  .areas-col-right{ position: sticky; top: 20px; margin-top: 0; }
}

.nav-row{ display:flex; justify-content:space-between; gap:12px; margin: 22px 0 60px; }
.nav-row .btn{ width:auto; min-width:130px; }

.room-tool-layout{ display:flex; flex-direction:column; gap:22px; align-items:stretch; }

.room3d-wrap{ position:relative; width:100%; aspect-ratio: 4 / 3; background:var(--paper-raise); border:1.5px solid var(--ink); border-radius:3px; overflow:hidden; }
.room3d-wrap canvas{ display:block; }
.room3d-status{ position:absolute; bottom:8px; inset-inline-start:8px; font-size:15px; font-weight:600; color:var(--ink); font-family:var(--font-mono); background:rgba(247,244,236,0.92); padding:5px 10px; border-radius:3px; }

.image4-wrap{ text-align:center; }
.image4-status{ font-size:14px; color:var(--ink-soft); padding:32px 16px; }
.image4-status.error{ color:var(--accent); }
.image4-result{ max-width:100%; width:520px; border:1.5px solid var(--ink); border-radius:3px; background:#fff; }
.image4-wrap .btn{ margin: 6px 6px 0; }
.image4-wrap textarea{ width:100%; max-width:520px; font-family:inherit; font-size:13.5px; padding:8px; border:1px solid var(--line); border-radius:3px; resize:vertical; }
.room-window-mark{ position:absolute; background: rgba(27,73,101,0.35); border: 2px solid var(--blueprint); }

.room-tool-2d{ text-align:center; }
.room-tool-2d-label{ font-size:12px; color:var(--ink-soft); margin-bottom:6px; font-family: var(--font-mono); }
.room-tool-step-label{ font-size:13px; font-weight:700; color:var(--blueprint); margin-bottom:8px; }
.theme-model-3d{ margin-top:16px; max-width:420px; }
.theme-model-3d .room3d-wrap{ aspect-ratio:4/3; }
.room2d-wall{ position:relative; background: var(--blueprint-tint); border: 1.5px solid var(--blueprint); border-radius: 2px; cursor: crosshair; margin: 0 auto; }

.space-header{ display:flex; align-items:center; gap:10px; margin: 34px 0 6px; }
.space-header .space-icon{ width:30px; height:30px; }
.space-header h2{ margin:0; font-size:20px; }
.space-header .space-num{ font-family:var(--font-mono); color:var(--blueprint); font-size:12px; }

/* ---------- consent panel ---------- */
.consent{ background: var(--blueprint-tint); border:1.5px solid var(--blueprint); border-radius: var(--radius); padding: 22px 24px; margin: 20px 0; }
.consent h2{ color: var(--blueprint-deep); font-size:18px; }
.consent p{ font-size:14.5px; color: var(--ink); }
.consent-contact{ font-size:13px; color: var(--ink-soft); margin-top:16px; padding-top:12px; border-top:1px dashed var(--line); }
.done-wrap .consent-contact{ max-width:56ch; margin-inline:auto; text-align:center; }
.consent .consent-parts{ font-size:14.5px; color: var(--ink); margin: 0 0 12px; padding-inline-start: 22px; }
.consent .consent-parts li{ margin-bottom: 6px; }

/* ---------- Done screen ---------- */
.done-wrap{ text-align:center; padding: 60px 0; }
.done-badge{ width:64px; height:64px; margin:0 auto 20px; }
.done-wrap h2{ font-size:24px; }
.done-wrap p{ color: var(--ink-soft); max-width: 46ch; margin: 8px auto 26px; }
.done-actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.done-actions .btn{ width:auto; }

footer.site-footer{ text-align:center; padding: 30px 0 50px; color: #000; font-size:12.5px; font-family: var(--font-mono); }

/* ---------- RTL adjustments ---------- */
[dir="rtl"] .select-wrap::after{ transform:translateY(-50%) scaleX(-1); }
[dir="rtl"] .kicker::before{ order:2; }
/* Keep Back/Next in the same physical spot as the English layout (Back on the left,
   Next on the right) even in Farsi — flipping them caused participants to repeatedly
   misclick Back instead of Next. */
[dir="rtl"] .nav-row{ flex-direction: row-reverse; }

.sr-only{ position:absolute; width:1px;height:1px; overflow:hidden; clip:rect(0,0,0,0); }

.fade-in{ animation: fadeIn .25s ease; }
@keyframes fadeIn{ from{ opacity:0; transform: translateY(6px);} to{ opacity:1; transform:none; } }
