/* ================================================================
   CONSTRAINT CANVAS — styles.css
   ================================================================ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  /* Brand colors — North by Normal */
  --teal:        #2C5F5F;
  --teal-light:  #3a7a7a;
  --teal-pale:   #E4EEEC;
  --orange:      #E07A3F;

  /* Oatmeal palette — warm, earthy, calm */
  --bg:          #FAF8F5;   /* warm white — page background */
  --surface:     #F2EDE6;   /* warm tan — empty section fill */
  --surface-2:   #EAE4DB;   /* slightly deeper tan */
  --border:      #DDD7CE;   /* warm gray border */
  --border-dark: #C4BDB4;   /* medium warm border */

  /* Text */
  --dark:        #292524;   /* warm near-black */
  --body:        #57534E;   /* warm medium brown-gray */
  --muted:       #A8A29E;   /* muted warm gray */

  /* Semantic aliases (used throughout) */
  --gray-100:    #F2EDE6;
  --gray-200:    #EAE4DB;
  --gray-400:    #C4BDB4;
  --gray-700:    #57534E;
  --white:       #FFFFFF;
  --green:       #4D7C62;   /* muted sage green */

  /* Section states */
  --section-empty:   #F2EDE6;
  --section-active:  #E4EEEC;
  --section-done:    #FFFFFF;

  /* Tokens */
  --radius:  6px;
  --shadow:  0 1px 3px rgba(41, 37, 36, 0.07), 0 1px 8px rgba(41, 37, 36, 0.04);
  --trans:   0.2s ease;

  /* Typography */
  --font-heading: 'Jost', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Zilla Slab', Georgia, serif;

  /* Aliases kept for safety during transition */
  --font-serif: var(--font-heading);
  --font-sans:  var(--font-body);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  color: var(--dark);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }


/* ================================================================
   BUTTONS
   ================================================================ */
.btn-primary {
  display: inline-block;
  background: var(--teal);
  color: var(--white);
  border: 2px solid var(--teal);
  padding: 11px 26px;
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--trans), transform var(--trans);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.btn-primary:hover {
  background: var(--teal-light);
  border-color: var(--teal-light);
  text-decoration: none;
}
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--teal);
  border: 1.5px solid var(--border-dark);
  padding: 9px 22px;
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--trans), border-color var(--trans);
  text-decoration: none;
}
.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--teal);
  text-decoration: none;
}

.btn-large { padding: 14px 36px; font-size: 1.05rem; }

/* Download PDF button — orange, distinct from other primary actions */
#download-btn {
  background: #F25E0C;
  border-color: #F25E0C;
}
#download-btn:hover {
  background: #d4520a;
  border-color: #d4520a;
}


/* ================================================================
   LANDING PAGE
   ================================================================ */
body.landing {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.site-header {
  padding: 20px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.site-header .logo { height: 34px; width: auto; }

main { flex: 1; }

/* Hero */
.hero {
  text-align: center;
  padding: 88px 24px 52px;
  max-width: 720px;
  margin: 0 auto;
}
.hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 300;
  color: var(--teal);
  line-height: 1.2;
  margin-bottom: 22px;
}
.hero .subhead {
  font-size: 1.15rem;
  color: var(--body);
  margin-bottom: 38px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.65;
  font-weight: 300;
}

/* Explainer */
.explainer {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 24px 52px;
  text-align: center;
  color: var(--body);
  font-size: 1rem;
  line-height: 1.7;
  font-weight: 300;
}

/* Canvas preview */
.canvas-preview {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px 52px;
}
.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.preview-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-full {
  grid-column: 1 / -1;
  background: var(--teal-pale);
  border-color: var(--teal);
  min-height: 52px;
}
.preview-sketch {
  grid-column: 1 / -1;
  min-height: 80px;
  background: var(--white);
  border-style: dashed;
}
.preview-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--body);
}
.preview-full .preview-label   { color: var(--teal); }
.preview-sketch .preview-label { color: var(--muted); }

.preview-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.cta-section {
  text-align: center;
  padding: 0 24px 88px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 40px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--white);
}


/* ================================================================
   APP PAGE — LAYOUT
   ================================================================ */
body.app {
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}


/* ================================================================
   CHAT PANEL (left)
   ================================================================ */
.chat-panel {
  width: 38%;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--white);
}

.chat-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.back-link {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}
.back-link:hover { color: var(--teal); text-decoration: none; }
.chat-header h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 300;
  color: var(--teal);
  margin-bottom: 12px;
  line-height: 1.3;
}

/* Progress bar */
.progress-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
}
.progress-label {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.msg {
  max-width: 90%;
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-ai {
  background: var(--white);
  color: var(--dark);
  align-self: flex-start;
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}
.msg-user {
  background: var(--teal);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.msg-system {
  background: var(--teal-pale);
  color: var(--teal);
  align-self: center;
  font-size: 0.825rem;
  text-align: center;
  border: 1px solid var(--teal);
  max-width: 100%;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 13px 15px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 2px;
  align-self: flex-start;
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--border-dark);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* Input area */
.chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--white);
}
#user-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--dark);
  resize: none;
  line-height: 1.5;
  transition: border-color var(--trans);
}
#user-input::placeholder { color: var(--muted); }
#user-input:focus {
  outline: none;
  border-color: var(--teal);
  background: var(--white);
}
#user-input:disabled { background: var(--surface); }
#send-btn { flex-shrink: 0; }
#send-btn:disabled {
  background: var(--border-dark);
  border-color: var(--border-dark);
  cursor: not-allowed;
}


/* ================================================================
   CANVAS PANEL (right)
   ================================================================ */
.canvas-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.canvas-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal);
}
.canvas-logo {
  height: 26px;
  width: auto;
}

/* Canvas grid — 2 columns */
.canvas-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  align-content: start;
}

/* Group labels ("Current State" / "Future State") */
.canvas-group-label {
  grid-column: 1 / -1;
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 6px 2px 0;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.canvas-section {
  background: var(--section-empty);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: background var(--trans), border-color var(--trans), box-shadow var(--trans);
  min-height: 90px;
}
.canvas-section.section-full {
  grid-column: 1 / -1;
  min-height: 70px;
}

/* Sketch section — tall, most space goes to drawing box */
.canvas-section.section-sketch {
  min-height: 160px;
}

/* Section states */
.canvas-section.state-active {
  background: var(--section-active);
  border-color: var(--teal);
}
.canvas-section.state-done {
  background: var(--section-done);
  border-color: var(--border-dark);
  box-shadow: var(--shadow);
}
.canvas-section.state-just-filled {
  animation: sectionPop 0.4s ease;
}
@keyframes sectionPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.015); box-shadow: 0 4px 14px rgba(44,95,95,0.15); }
  100% { transform: scale(1); }
}

.section-label {
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--teal);
}
.section-content {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  flex: 1;
  font-style: italic;
}
.canvas-section.state-done .section-content {
  color: var(--dark);
  font-style: normal;
}
.canvas-section.state-active .section-content {
  color: var(--body);
  font-style: normal;
}

/* Sketch drawing box */
.sketch-box {
  flex: 1;
  border: 1.5px dashed var(--border-dark);
  border-radius: 4px;
  min-height: 100px;
  background: var(--white);
}

/* Canvas actions (download button) */
.canvas-actions {
  padding: 12px;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: none;
}
.canvas-actions.visible { display: block; }
#download-btn { width: 100%; }


/* ================================================================
   COMPLETION SCREEN
   ================================================================ */
.completion-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 24px;
}
.completion-screen[hidden] { display: none !important; }

.completion-inner {
  max-width: 580px;
  width: 100%;
}

.completion-check {
  width: 52px;
  height: 52px;
  background: var(--green);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 22px;
}
.completion-inner h2 {
  font-family: var(--font-heading);
  font-size: 1.9rem;
  font-weight: 300;
  color: var(--teal);
  margin-bottom: 8px;
  line-height: 1.2;
}
.completion-inner > p {
  color: var(--body);
  margin-bottom: 20px;
}

.next-steps {
  padding-left: 18px;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--body);
}
.next-steps li { font-size: 0.975rem; line-height: 1.6; }

.cta-box {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 30px;
  margin-bottom: 28px;
}
.cta-box h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--teal);
  margin-bottom: 10px;
}
.cta-box p {
  color: var(--body);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.completion-secondary {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.feedback-link {
  font-size: 0.875rem;
  color: var(--muted);
}
.feedback-link:hover { color: var(--teal); }


/* ================================================================
   PRINT / PDF STYLES
   ================================================================ */

/* Hide print-only content on screen */
.print-page-2 { display: none; }

@media print {

  body {
    height: auto;
    overflow: visible;
    font-size: 10pt;
    background: white;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .chat-panel,
  .canvas-actions,
  .completion-screen {
    display: none !important;
  }

  body.app {
    height: auto;
    overflow: visible;
  }

  .app-layout {
    display: block;
    height: auto;
  }

  .canvas-panel {
    width: 100%;
    height: auto;
    overflow: visible;
    background: white;
  }

  /* Canvas header — shown in print */
  .canvas-header {
    display: flex !important;
    padding: 0 0 10pt 0;
    border-bottom: 1.5pt solid #2C5F5F;
    margin-bottom: 10pt;
    background: white;
  }
  .canvas-title {
    font-size: 13pt;
    font-weight: 700;
    letter-spacing: 0.08em;
  }
  .canvas-logo { height: 28pt; }

  /* Canvas grid — 2-col, explicit row heights matching wireframe */
  .canvas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows:
      auto       /* Constraint Snapshot */
      auto       /* "Current State" group label */
      auto       /* Source & Purpose + Tension Points */
      220pt      /* Sketch (tall) */
      auto       /* "Future State" group label */
      auto       /* Creative Opps + Outcome Metrics */
      auto;      /* First Moves */
    gap: 6pt;
    padding: 0;
    overflow: visible;
  }

  /* Group labels */
  .canvas-group-label {
    grid-column: 1 / -1;
    font-size: 6pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #A8A29E;
    padding: 3pt 0 0;
    border-top: 0.5pt solid #DDD7CE;
  }

  .canvas-section {
    border: 0.75pt solid #DDD7CE;
    border-radius: 3pt;
    padding: 7pt 9pt;
    background: white !important;
    break-inside: avoid;
    display: flex;
    flex-direction: column;
    gap: 4pt;
  }
  .canvas-section.section-full {
    grid-column: 1 / -1;
  }

  .section-label {
    font-size: 6.5pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #2C5F5F;
    flex-shrink: 0;
  }
  .section-content {
    font-size: 9pt;
    color: #292524;
    line-height: 1.5;
    flex-shrink: 0;
    font-style: normal;
  }
  .section-content[data-placeholder="true"] {
    color: #C4BDB4;
    font-style: italic;
  }

  /* Sketch box — fills the 220pt row */
  .sketch-box {
    flex: 1;
    border: 0.75pt dashed #C4BDB4;
    border-radius: 3pt;
    background: white;
    margin-top: 3pt;
    min-height: 160pt;
  }

  /* Page 2 — Next Steps */
  .print-page-2 {
    display: block;
    page-break-before: always;
    background: white;
  }
  .print-page-2 h2 {
    font-size: 15pt;
    font-weight: 700;
    color: #2C5F5F;
    border-bottom: 1.5pt solid #2C5F5F;
    padding-bottom: 7pt;
    margin-bottom: 14pt;
  }
  .print-section { margin-bottom: 13pt; }
  .print-section h3 {
    font-size: 10pt;
    font-weight: 700;
    color: #2C5F5F;
    margin-bottom: 4pt;
  }
  .print-section p {
    font-size: 9.5pt;
    line-height: 1.6;
    color: #292524;
    margin-bottom: 3pt;
  }
  .print-cta {
    background: #E4EEEC;
    border: 1pt solid #2C5F5F;
    border-radius: 3pt;
    padding: 13pt 15pt;
    margin-top: 16pt;
  }
  .print-cta h3 {
    font-size: 11pt;
    font-weight: 700;
    color: #2C5F5F;
    margin-bottom: 5pt;
  }
  .print-cta p {
    font-size: 9.5pt;
    line-height: 1.6;
    color: #292524;
    margin-bottom: 5pt;
  }
  .print-feedback { font-size: 8pt; color: #A8A29E; }
  .print-footer {
    margin-top: 16pt;
    border-top: 0.5pt solid #DDD7CE;
    padding-top: 6pt;
    font-size: 7.5pt;
    color: #A8A29E;
    text-align: center;
  }

  a::after { content: none !important; }
}


/* ================================================================
   RESPONSIVE — MOBILE / TABLET
   ================================================================ */
@media (max-width: 768px) {

  body.app {
    height: auto;
    overflow: auto;
  }

  .app-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .chat-panel {
    width: 100%;
    height: 55vh;
    min-height: 360px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .canvas-panel {
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .canvas-grid {
    grid-template-columns: 1fr 1fr;
    overflow: visible;
  }

  .canvas-actions.visible {
    position: sticky;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(41,37,36,0.1);
    z-index: 10;
  }

  .hero h1  { font-size: 2rem; }
  .site-header { padding: 16px 20px; }
  .cta-section { padding-bottom: 52px; }
}

@media (max-width: 480px) {
  .canvas-grid { grid-template-columns: 1fr; }
  .canvas-section.section-full { grid-column: 1; }
  .completion-screen { padding: 32px 16px; }
  .cta-box { padding: 20px; }
  .completion-secondary { flex-direction: column; align-items: flex-start; }
}
