/* Fabriqué au Canada — Central Stylesheet */

/* ── Design tokens (light default) ── */
:root, :root[data-theme="light"] {
  --color-bg: #fafafa;
  --color-surface: #fff;
  --color-text: #1a1a1a;
  --color-text-muted: #666;
  --color-text-dim: #444;
  --color-text-faint: #999;
  --color-accent: #c8102e;
  --color-accent-hover: #a00d24;
  --color-border: #e0e0e0;
  --color-border-light: #ddd;
  --color-border-faint: #f0f0f0;
  --color-disabled: #ccc;
}

/* ── Dark: system preference (no toggle yet) ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-text: #e8e8e8;
    --color-text-muted: #aaa;
    --color-text-dim: #bbb;
    --color-text-faint: #777;
    --color-accent: #e0354e;
    --color-accent-hover: #ff4d66;
    --color-border: #333;
    --color-border-light: #444;
    --color-border-faint: #2a2a2a;
    --color-disabled: #555;
  }
}

/* ── Dark: explicit toggle ── */
:root[data-theme="dark"] {
  --color-bg: #121212;
  --color-surface: #1e1e1e;
  --color-text: #e8e8e8;
  --color-text-muted: #aaa;
  --color-text-dim: #bbb;
  --color-text-faint: #777;
  --color-accent: #e0354e;
  --color-accent-hover: #ff4d66;
  --color-border: #333;
  --color-border-light: #444;
  --color-border-faint: #2a2a2a;
  --color-disabled: #555;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Footer ── */
.site-footer {
  margin-top: auto;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-faint);
  border-top: 1px solid var(--color-border-faint);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.footer-links a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s;
}

.footer-links a:hover {
  color: var(--color-accent);
}

/* ── Top nav ── */
.top-nav {
  position: absolute;
  top: 1rem;
  left: 1.5rem;
  right: 1.5rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-nav .theme-toggle {
  margin-left: auto;
}

.top-nav-link {
  text-decoration: none;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  transition: border-color 0.15s, color 0.15s;
}

.top-nav-link:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Language buttons (desktop) */
.lang-buttons {
  display: flex;
  gap: 0.25rem;
}

button.top-nav-link {
  background: none;
  cursor: pointer;
  font-family: inherit;
}

button.top-nav-link.lang-active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: 600;
}

/* Language dropdown (mobile only) */
.lang-form-mobile {
  display: none;
}

.lang-select {
  appearance: none;
  background: none;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  padding: 0.35rem 1.5rem 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.lang-select:hover, .lang-select:focus {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ── Theme toggle ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  line-height: 1;
}

.theme-toggle::before {
  content: "\263E";
}

:root[data-theme="dark"] .theme-toggle::before {
  content: "\2600";
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle::before {
    content: "\2600";
  }
}

.theme-toggle:hover {
  border-color: var(--color-accent);
}

/* ── Landing page ── */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2rem;
}

.header {
  text-align: center;
  margin-bottom: 1.5rem;
  margin-top: 2rem;
}

.brand {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.intro {
  max-width: 800px;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--color-text-dim);
  margin-bottom: 0.5rem;
}

/* ── Alpha notice ── */
.alpha-notice {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
}

.alpha-notice a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}

.alpha-notice a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* ── Agent cards ── */
.agents {
  display: flex;
  gap: 2.5rem;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 900px;
}

.agent-card {
  flex: 1 1 340px;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.agent-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 8px 24px rgba(200, 16, 46, 0.12);
  transform: translateY(-2px);
}

.agent-avatar {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--color-accent);
  margin-bottom: 1.25rem;
}

.agent-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.agent-role {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  font-weight: 600;
  margin-bottom: 1rem;
}

.agent-desc {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.agent-examples {
  width: 100%;
  text-align: left;
}

.agent-examples p {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.agent-examples ul {
  list-style: none;
}

.agent-examples li {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border-faint);
}

.agent-examples li:last-child {
  border-bottom: none;
}

.agent-examples li::before {
  content: "\201C";
  color: var(--color-accent);
  font-weight: 600;
  margin-right: 0.25rem;
}

.agent-examples li::after {
  content: "\201D";
  color: var(--color-accent);
  font-weight: 600;
  margin-left: 0.1rem;
}

.chat-cta {
  display: inline-block;
  margin-top: auto;
  padding: 0.6rem 1.75rem;
  background: var(--color-accent);
  color: #fff;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s;
}

.agent-card:hover .chat-cta {
  background: var(--color-accent-hover);
}

/* ── Chat layout ── */
.chat-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Hide site nav and footer on chat pages — chat has its own header */
body:has(.chat-body) .site-footer { display: none; }
body:has(.chat-body) .top-nav { display: none; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.back-link {
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--color-accent);
}

.chat-agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--color-accent);
  object-fit: cover;
}

.chat-agent-info {
  display: flex;
  flex-direction: column;
}

.chat-agent-name {
  font-weight: 700;
  font-size: 1rem;
}

.chat-agent-role {
  font-size: 0.75rem;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* ── Messages ── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.msg {
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.msg-user {
  align-self: flex-end;
  background: var(--color-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-agent {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  max-width: 80%;
}

.msg-agent-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--color-accent);
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-agent-text {
  flex: 1;
}

.msg-agent-text p { margin: 0 0 0.5em; }
.msg-agent-text p:last-child { margin-bottom: 0; }
.msg-agent-text ul, .msg-agent-text ol { margin: 0.25em 0 0.5em 1.25em; }
.msg-agent-text li { margin-bottom: 0.2em; }
.msg-agent-text strong { font-weight: 600; }
.msg-agent-text a { color: var(--color-accent); text-decoration: underline; }
.msg-agent-text a:hover { color: var(--color-accent-hover); }
.msg-agent-text code { background: var(--color-border-faint); padding: 0.1em 0.3em; border-radius: 3px; font-size: 0.85em; }
.msg-agent-text h1, .msg-agent-text h2, .msg-agent-text h3 { font-size: 1em; font-weight: 700; margin: 0.75em 0 0.25em; }
.msg-agent-text blockquote { border-left: 3px solid var(--color-border); padding-left: 0.75em; margin: 0.5em 0; color: var(--color-text-muted); }

/* ── Chat input ── */
.chat-input-area {
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  gap: 0.75rem;
}

.chat-input {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid var(--color-border-light);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s;
}

.chat-input:focus {
  border-color: var(--color-accent);
}

.chat-send {
  padding: 0.7rem 1.5rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-send:hover {
  background: var(--color-accent-hover);
}

.chat-send:disabled {
  background: var(--color-disabled);
  cursor: not-allowed;
}

.htmx-request .chat-send {
  background: var(--color-disabled);
  pointer-events: none;
}

/* ── Typing indicator ── */
.typing-dots span {
  font-size: 1.5rem;
  line-height: 1;
  animation: typing-pulse 1.4s infinite;
  display: inline-block;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-pulse {
  0%, 60%, 100% { opacity: 0.2; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ── About page ── */
.about-content {
  max-width: 640px;
  text-align: left;
  line-height: 1.7;
  color: var(--color-text-dim);
}

.about-section {
  margin-bottom: 2.5rem;
}

.about-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.75rem;
}

.about-section p {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.about-section ul {
  list-style: none;
  padding: 0;
}

.about-section li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border-faint);
}

.about-section li::before {
  content: "🍁";
  margin-right: 0.5rem;
}

.about-section li:last-child {
  border-bottom: none;
}

.about-definitions {
  margin: 1rem 0 1.5rem;
}

.about-definitions dt {
  font-weight: 700;
  color: var(--color-text);
  margin-top: 1rem;
}

.about-definitions dt:first-child {
  margin-top: 0;
}

.about-definitions dd {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--color-accent);
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.resource-list {
  list-style: none;
  padding: 0;
}

.resource-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border-faint);
  line-height: 1.6;
}

.resource-list li:last-child {
  border-bottom: none;
}

.resource-list li::before {
  content: none;
}

.resource-list a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}

.resource-list a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.about-back {
  margin-top: 2rem;
}

.about-back a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}

.about-back a:hover {
  color: var(--color-accent-hover);
}

/* ── Feedback form ── */
.feedback-intro {
  font-size: 1rem;
  color: var(--color-text-dim);
  margin-bottom: 1rem;
}

.feedback-conversation-note {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.feedback-field {
  margin-bottom: 1.25rem;
}

.feedback-field > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.35rem;
}

.feedback-type-group {
  border: none;
  padding: 0;
}

.feedback-type-group legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.feedback-type-group .feedback-radios {
  display: flex;
  gap: 1.5rem;
}

.feedback-radio {
  font-size: 0.95rem;
  font-weight: normal;
  color: var(--color-text-dim);
  cursor: pointer;
}

.feedback-field select,
.feedback-field > input,
.feedback-field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border-light);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s;
}

.feedback-field select:focus,
.feedback-field input:focus,
.feedback-field textarea:focus {
  border-color: var(--color-accent);
}

.feedback-field textarea {
  resize: vertical;
}

.feedback-error {
  color: var(--color-accent);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.feedback-success {
  text-align: center;
  padding: 2rem 0;
  color: var(--color-text-dim);
}

.feedback-success p:first-child {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

/* ── Chat feedback link ── */
.feedback-link {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.feedback-link:hover {
  color: var(--color-accent);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .top-nav {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    gap: 0.4rem;
  }
  .lang-buttons { display: none; }
  .lang-form-mobile { display: block; }
  .header { margin-top: 0.5rem; }
  .chat-header { padding: 0.5rem 0.75rem; gap: 0.5rem; }
  .chat-input-area { padding: 0.75rem; }
  .feedback-link { font-size: 0.65rem; }
}

@media (max-width: 480px) {
  .brand { font-size: 1.75rem; }
  .agents { gap: 1.5rem; }
  .agent-card { padding: 2rem 1.5rem; }
  .agent-avatar { width: 120px; height: 120px; }
  .top-nav { gap: 0.3rem; }
  .top-nav-link { font-size: 0.7rem; padding: 0.25rem 0.5rem; }
  .lang-select { font-size: 0.7rem; padding: 0.25rem 1.25rem 0.25rem 0.5rem; }
}