/* =========================================================================
   Gaëtan Costa-Mula — personal site
   Palette: porcelain / graphite ink / copper (the conductor of the energy
   transition) / slate. The chat card is the only dark object on the page.
   Type: Archivo (display, semi-expanded) · IBM Plex Sans (body)
         · IBM Plex Mono (metrics, dates, labels — the engineering register)
   ========================================================================= */

:root {
  --porcelain: #f6f7f5;
  --ink: #1b1d1f;
  --slate: #5c6470;
  --copper: #b26b2b;
  --copper-soft: #d99a5b;
  --console: #14161a;
  --console-line: #2a2e35;
  --console-text: #e8e6e1;
  --radius: 14px;
  --max: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--porcelain);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.02em;
}

h1, h2, h3 {
  font-family: "Archivo", system-ui, sans-serif;
  font-variation-settings: "wdth" 110;
  line-height: 1.08;
  margin: 0;
}

button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}

/* ---------- top bar ---------------------------------------------------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 247, 245, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, padding 0.2s;
}

.topbar.is-scrolled {
  padding: 10px 24px;
  border-bottom-color: #e3e2dd;
}

.topbar-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 440px;
  margin: 0 20px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.topbar.is-scrolled .topbar-chat {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--copper);
  flex-shrink: 0;
}

.topbar-chat input {
  width: 100%;
  border: 1px solid #e3e2dd;
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  outline: none;
  color: var(--ink);
}

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

.progress-bar {
  position: sticky;
  top: 0;
  height: 2px;
  background: var(--copper);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 51;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.topbar-name { font-size: 12px; color: var(--slate); }

.lang { display: flex; gap: 4px; }

.lang button {
  border: 1px solid transparent;
  background: none;
  color: var(--slate);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
}

.lang button[aria-pressed="true"] {
  color: var(--copper);
  border-color: var(--copper);
}

/* ---------- hero -------------------------------------------------------- */

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: 44px 24px 28px;
  text-align: center;
}

.eyebrow {
  font-size: 12px;
  color: var(--copper);
  margin: 0 0 20px;
}

.portrait {
  display: block;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 2px solid var(--copper);
  opacity: 0;
  filter: blur(8px);
  transition: opacity 0.6s ease, filter 0.6s ease;
  will-change: transform;
}

.portrait.is-loaded {
  opacity: 1;
  filter: none;
}

.hero h1 {
  font-size: clamp(2.4rem, 6.5vw, 4.2rem);
  font-weight: 800;
}

.hero h1 .accent { color: var(--copper); }

.hero-sub {
  max-width: 680px;
  margin: 18px auto 8px;
  color: var(--slate);
  font-size: 18px;
}

.cred {
  font-size: 12px;
  color: var(--copper);
  opacity: 0.8;
  margin: 0 auto 26px;
}

/* ---------- chat card (the signature element) --------------------------- */

.chat-card {
  max-width: 780px;
  margin: 0 auto;
  background: var(--console);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: 0 18px 50px rgba(20, 22, 26, 0.22);
  text-align: left;
}

.chat-messages {
  display: none;
  flex-direction: column;
  gap: 10px;
  max-height: 0;
  overflow-y: auto;
  padding: 6px 8px;
  transition: max-height 0.45s ease;
}

.chat-card.is-active .chat-messages {
  display: flex;
  max-height: min(620px, 62vh);
  padding: 12px 8px 14px;
}

.chat-bubble {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

.chat-assistant {
  align-self: flex-start;
  background: var(--console-line);
  color: var(--console-text);
  border-bottom-left-radius: 4px;
}

.chat-typing {
  opacity: 0.6;
  font-style: italic;
  animation: typing-pulse 1.1s ease-in-out infinite;
}

@keyframes typing-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1d2026;
  border: 1px solid var(--console-line);
  border-radius: 10px;
  padding: 6px 6px 6px 14px;
}

.chat-caret { color: var(--copper-soft); font-size: 15px; }

.chat-form input {
  flex: 1;
  border: none;
  background: none;
  color: var(--console-text);
  font-size: 16px;
  outline: none;
  min-width: 0;
}

.chat-form input::placeholder { color: #7a8290; }

.chat-send {
  border: none;
  background: var(--copper);
  color: #fff;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
}

.chat-send:hover { background: var(--copper-soft); }

.chat-chips {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding: 10px 4px 4px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
}

.chat-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
}

.chip {
  border: 1px solid var(--console-line);
  background: none;
  color: #aab2bd;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  transition: color 0.15s, border-color 0.15s;
}

.chip:hover { color: var(--copper-soft); border-color: var(--copper); }

.chat-card.is-active .chat-chips { display: none; }

.chat-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 4px 8px;
}

.chat-suggest .chip {
  flex-shrink: 1;
  white-space: normal;
  text-align: left;
}

/* ---------- story invite (below the chat) --------------------------------- */

.story-invite {
  display: block;
  text-align: center;
  margin: 26px auto 0;
  font-size: 13px;
  color: var(--copper);
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s, color 0.15s;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
  animation: invite-bounce 2.2s ease-in-out 6;
}

@keyframes invite-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.story-invite:hover {
  opacity: 1;
  color: var(--copper-soft);
  animation-play-state: paused;
}

.story-intro {
  text-align: center;
  color: var(--slate);
  font-size: 15px;
  max-width: 480px;
  margin: 0 auto 56px;
  line-height: 1.6;
}

/* ---------- story timeline (unified narrative below the chat) ----------- */

.story {
  max-width: 780px;
  margin: 0 auto;
  padding: 70px 24px 90px;
  scroll-margin-top: 40px;
}

.story-list {
  list-style: none;
  margin: 0;
  padding: 20px 0;
  position: relative;
}

.story-list::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom, var(--copper) 0 12px, transparent 12px 26px);
  border-radius: 2px;
}

.story-node {
  position: relative;
  width: calc(50% - 26px);
  margin-bottom: 52px;
}

.story-node:last-child { margin-bottom: 0; }

.story-node:nth-child(odd) { margin-right: auto; text-align: right; }
.story-node:nth-child(even) { margin-left: auto; text-align: left; }

.story-index {
  position: absolute;
  top: 2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--porcelain);
  border: 2px solid var(--copper);
  color: var(--copper);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.story-node:nth-child(odd) .story-index { right: -41px; }
.story-node:nth-child(even) .story-index { left: -41px; }

.story-node > div {
  padding: 6px 14px;
  border-radius: 10px;
  transition: background 0.2s;
}

.story-node:hover > div { background: #fff; }

.story-hook {
  font-family: "Archivo", system-ui, sans-serif;
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 6px;
  line-height: 1.25;
}

.story-teaser {
  color: var(--slate);
  font-size: 15px;
  margin: 0 0 12px;
}

.story-cta {
  border: none;
  background: none;
  color: var(--copper);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  letter-spacing: 0.02em;
}

.story-cta:hover { color: var(--copper-soft); }

/* ---------- footer -------------------------------------------------------- */

.footer {
  border-top: 1px solid #e3e2dd;
  text-align: center;
  padding: 40px 24px 56px;
  color: var(--slate);
  font-size: 14px;
}

.footer .mono { font-size: 12px; }

.privacy {
  font-size: 11px;
  color: var(--slate);
  opacity: 0.75;
  max-width: 520px;
  margin: 14px auto 0;
  line-height: 1.5;
}

/* ---------- contact rail (hidden side bar, icons only) -------------------- */

.contact-rail {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translate(55%, -50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 12px 12px;
  background: #fff;
  border: 1px solid #e3e2dd;
  border-right: none;
  border-radius: 14px 0 0 14px;
  box-shadow: 0 6px 20px rgba(27, 29, 31, 0.08);
  opacity: 0.55;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 60;
}

.contact-rail:hover,
.contact-rail:focus-within,
.contact-rail.is-open {
  transform: translate(0, -50%);
  opacity: 1;
}

.rail-link {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid #e3e2dd;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.rail-link:hover {
  border-color: var(--copper);
  color: var(--copper);
}

.rail-link-cta {
  background: var(--copper);
  border-color: var(--copper);
  color: #fff;
}

.rail-link-cta:hover {
  background: var(--copper-soft);
  color: #fff;
}

/* ---------- responsive ----------------------------------------------------- */

@media (max-width: 760px) {
  .story-list::before { left: 14px; transform: none; }
  .story-node {
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    text-align: left !important;
    padding-left: 40px;
  }
  .story-node .story-index { left: -1px !important; right: auto !important; }
  .hero { padding-top: 36px; }
  .chat-card.is-active .chat-messages { max-height: 52vh; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
