/* ============================================================
   SOFAI — Styles
   Reset + base type + shared components. Reads top to bottom:
   reset → typography → layout → buttons → header/footer → landing.
   Tokens come from theme.css; fonts from fonts.css.
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: hidden; }
img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Base ---------- */
body {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  text-transform: lowercase;          /* body is all-lowercase */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* sticky footer: footer rests at viewport bottom on short pages */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Headings: Oswald, all-caps, tight + tracked */
h1, h2, h3, h4, .head {
  font-family: var(--font-head);
  text-transform: uppercase;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.04em;
}
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p { max-width: var(--measure); }

/* Proper nouns / things that shouldn't be forced lowercase */
.caps { text-transform: uppercase; }
.normal-case { text-transform: none; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-3);
}
.section { padding-block: var(--space-3); }
.center { text-align: center; }
.stack > * + * { margin-top: var(--space-2); }

.eyebrow {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: var(--step--1);
  color: var(--olive);
}

/* ---------- Buttons (mirrors interactivecourse button system) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.86rem;
  padding: 0.42rem 1.7rem;
  border: 1px solid var(--olive);
  border-radius: 0;
  background: var(--olive);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.btn:hover { background: var(--olive-hover); border-color: var(--olive-hover); }

/* solid olive primary (default look) */
.btn--primary { background: var(--olive); color: #fff; }
/* olive on brand olive == kept for clarity / legacy markup */
.btn--olive { background: var(--olive); border-color: var(--olive); color: #fff; }

/* outlined: transparent with olive text, fills olive on hover */
.btn--ghost { background: transparent; color: var(--olive); }
.btn--ghost:hover { background: var(--olive-hover); color: #fff; border-color: var(--olive-hover); }

/* size + width modifiers */
.btn--sm { padding: 0.42rem 0.9rem; font-size: 0.72rem; }
.btn--lg { padding: 0.42rem 2.4rem; font-size: 0.95rem; }
.btn--block { width: 100%; margin-top: 0.6rem; }

.btn:disabled, .btn.is-disabled { opacity: 0.5; pointer-events: none; }

/* ---------- Header (matches interactivecourse topbar) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem clamp(1rem, 4vw, 2.4rem);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: inline-flex; cursor: pointer; }
.topbar__brand img { height: 74px; width: auto; }
.topbar__right { display: flex; align-items: center; gap: 0.6rem; }

/* ---------- Footer (matches interactivecourse sitefoot) ---------- */
.sitefoot {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.8rem clamp(1rem, 4vw, 2.4rem);
}
.sitefoot::before {
  content: "";
  position: absolute;
  top: 0;
  left: clamp(1rem, 4vw, 2.4rem);
  right: clamp(1rem, 4vw, 2.4rem);
  border-top: 1px solid var(--line);
}
.sitefoot__short { font-style: italic; color: var(--black); text-align: left; }
.sitefoot__copy {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.82rem;
  color: var(--black);
  text-align: right;
}

/* ============================================================
   LOGIN — single centered job: get them signed in.
   Mirrors the interactivecourse login feel.
   ============================================================ */
.login {
  flex: 1 0 auto;                 /* fill space between header and footer */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 4vw, 2.4rem);
}
.login__inner { width: 100%; max-width: 30rem; }
/* headline = course .display + .hero__welcome (big, bold-feeling Oswald caps) */
.login h1 {
  font-family: var(--font-head);
  text-transform: uppercase;
  font-weight: 400;
  font-size: clamp(2.7rem, 5.4vw, 3.9rem);
  line-height: 1.03;
  letter-spacing: normal;
  color: var(--black);
  margin: 0;
}
.hero__accent { color: var(--olive); }
.login .lede {
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0.9rem auto 0;
  max-width: 46ch;
}
.login__actions { margin-top: 1.6rem; }

/* Magic-link form — always visible, matched to course .auth-form / .field__input */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-width: 24rem;
  margin: 0 auto;
  text-align: left;
}
.auth-form .field__input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 1rem 1.1rem;
  text-transform: lowercase;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.auth-form .field__input::placeholder { color: #a7a99c; font-style: italic; }
.auth-form .field__input:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(99, 107, 73, 0.12);
}
.auth-form__msg {
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1em;
  margin: 0;
}
.auth-form__msg.is-error { color: #a23b2d; }
.auth-form__msg.is-ok { color: var(--olive); }

/* ---------- The method: phase cards (Scope / Discover / Vision) ---------- */
.phase-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.phase-card {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.6rem 0.9rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}
.phase-card:hover { border-color: var(--olive); box-shadow: var(--shadow); }
.phase-card__num {
  font-family: var(--font-head);
  color: var(--chrome);
  font-size: 0.95rem;
}
.phase-card h3 {
  font-family: var(--font-head);
  font-size: 1.1rem;
  color: var(--olive);
  letter-spacing: 0.04em;
  margin: 0.05rem 0 0;
}
.phase-card p {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0.15rem 0 0;
  max-width: none;
}

/* ---------- Pricing ---------- */
.pricing-head { text-align: center; }
.pricing-head .eyebrow { margin-bottom: 0.3rem; }
.pricing-head p { margin: 0 auto; font-size: 0.92rem; }
.pricing {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  max-width: 720px;
  margin: 0.7rem auto 0;
}
.price-card {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.7rem 0.9rem 0.8rem;
  background: var(--white);
}
.price-card .eyebrow { margin: 0; }
.price-card .amount {
  font-family: var(--font-head);
  font-size: 1.7rem;
  line-height: 1.05;
}
.price-card .amount span { font-size: 0.95rem; color: var(--muted); }
.price-card p { font-size: 0.8rem; margin: 0; max-width: none; }
.price-card.is-feature { background: var(--olive-tint); border-color: var(--olive); }
.price-card .btn { margin-top: 0.45rem; align-self: flex-start; padding: 0.6em 1.4em; }

/* ---------- Utility ---------- */
.divider { height: 1px; background: var(--line); border: 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* Shared page heading (= course .display) used on dashboard / status pages */
.page-title {
  font-family: var(--font-head);
  text-transform: uppercase;
  font-weight: 400;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.04;
  letter-spacing: 0.02em;
  color: var(--black);
  margin: 0;
}

/* ============================================================
   LOGGED-IN ACCOUNT SLOT (header right) — mirrors course
   ============================================================ */
.account { display: flex; align-items: center; gap: 0.6rem; }
.account__email {
  font-family: var(--font-body);
  text-transform: lowercase;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}

/* Standard page-content column (header → view → footer) */
.view {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding: clamp(1.2rem, 3vw, 2.2rem) clamp(1rem, 4vw, 2.4rem) clamp(1.5rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2.4vw, 1.6rem);
}

/* ---------- Loading state (prevents the pre-load content flash) ---------- */
.page-loading {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-2);
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-top-color: var(--olive);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   DASHBOARD — your rooms
   ============================================================ */
.dashboard { text-align: center; }
.dashboard .lede { margin: 0.6rem auto 0; max-width: 46ch; }
.br-mobile { display: none; }   /* forced line break shown on mobile only */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.7rem;
  margin-top: 1.6rem;
  text-align: left;
}
.room-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.8rem;
  min-height: 9.5rem;
  padding: 1.05rem 1.15rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}
.room-card:hover { border-color: var(--olive); box-shadow: var(--shadow); }
.room-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.room-card__name {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 1.25rem;
  color: var(--olive);
}
/* the "start your first room" card heading reads in black, not olive */
.room-card--first .room-card__name { color: var(--black); }
/* small, quiet "rename" affordance top-right of the card */
.room-card__rename {
  flex: 0 0 auto;
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.62rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}
.room-card__rename:hover { color: var(--olive); }
/* inline edit input (replaces the name while editing) */
.room-card__edit {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.4;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--olive);
  border-radius: 0;
  padding: 0.3rem 0.45rem;
  text-transform: lowercase;
}
.room-card__edit:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 107, 73, 0.12);
}
.room-card .btn { align-self: flex-start; }
/* add-a-room card */
.room-add {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.3rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  border-style: dashed;
}
.room-add:hover { border-style: solid; }
.room-add__plus { font-family: var(--font-head); font-size: 2.2rem; line-height: 1; color: var(--olive); }
.room-add__label {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.86rem;
  color: var(--ink);
}

/* ============================================================
   CHAT — the SOFAI conversation
   ============================================================ */
.page--chat { height: 100vh; height: 100dvh; overflow: hidden; }
.chat {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;            /* lets the log scroll instead of the page */
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
}
.chat__roomname {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.6rem clamp(1rem, 4vw, 2.4rem) 0;
  flex: 0 0 auto;
}
.chat__log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  /* generous bottom padding so messages never hide behind the fixed input bar */
  padding: 1rem clamp(1rem, 4vw, 2.4rem) 7.5rem;
}
.msg {
  font-family: var(--font-body);
  text-transform: lowercase;
  line-height: 1.55;
  font-size: 1rem;
  max-width: 78%;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg--sofai { align-self: flex-start; background: var(--olive-tint); border-color: #e2e6da; }
.msg--user  { align-self: flex-end;   background: #fff; }
.msg--typing { color: var(--muted); font-style: italic; }
/* input bar pinned to the bottom of the viewport at all times */
.chat__foot {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  border-top: 1px solid var(--line);
  padding: 0.55rem clamp(1rem, 4vw, 2.4rem) calc(0.8rem + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
}
.chat__foot-inner {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
}
.chat__counter {
  font-family: var(--font-body);
  text-transform: lowercase;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: left;
  margin-bottom: 0.5rem;
}
.chat__inputbar { display: flex; gap: 0.5rem; align-items: stretch; }
.chat__input {
  flex: 1 1 auto;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.7rem 0.95rem;
  text-transform: lowercase;
  resize: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.chat__input::placeholder { color: #a7a99c; font-style: italic; }
.chat__input:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(99, 107, 73, 0.12);
}
.chat__inputbar .btn { flex: 0 0 auto; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .view { gap: 1.1rem; }
  .phase-grid { grid-template-columns: 1fr; gap: 0.5rem; }
  .pricing { grid-template-columns: 1fr; }

  /* footer tagline: match course mobile size (its body shrinks to 16px) */
  .sitefoot__short { font-size: 1rem; }

  /* topbar (mobile) — matched to interactivecourse: logo left, LOG IN right.
     We keep the button (no hamburger). White bg, overflow hidden. */
  .topbar {
    padding: 0.4rem 1rem;
    gap: 0.5rem;
    overflow: hidden;
    background: #fff;
    backdrop-filter: none;
  }
  /* logo: course size (70px) + same left pull so it aligns to the content edge */
  .topbar__brand img { height: 70px; margin-left: -19px; }
  /* LOG IN sized proportionate to the larger logo */
  .topbar__right .btn { letter-spacing: 0.1em; }

  /* headline steps down so it never runs past the screen edge */
  .login { padding-left: 1.1rem; padding-right: 1.1rem; }
  .login h1 { font-size: clamp(2.4rem, 11vw, 3.2rem); }
  .login .lede { font-size: 1.05rem; }
  /* the pricing line can't fit on one line on a phone — let it wrap here */
  .login .lede.nowrap { white-space: normal; }

  /* logged-in header: keep email visible but let it truncate, keep SIGN OUT */
  .account { gap: 0.4rem; }
  .account__email { max-width: 38vw; font-size: 0.78rem; }
  .topbar__right .btn--sm { padding: 0.42rem 0.7rem; }

  /* dashboard + chat fit the phone */
  .page-title { font-size: clamp(2rem, 10vw, 2.8rem); }
  .rooms-grid { grid-template-columns: 1fr; margin-top: 0; }
  .msg { max-width: 86%; }

  /* dashboard: center the heading+subtext with equal space above and below */
  .dashboard { padding-top: 0; gap: 0; }
  .dashboard__intro { margin-block: clamp(2rem, 11vh, 5.5rem); }

  /* show the forced break so the subtext reads as two lines */
  .br-mobile { display: inline; }
}

@media (max-width: 380px) {
  .login h1 { font-size: clamp(2.1rem, 12vw, 2.6rem); }
  .account__email { max-width: 32vw; }
}
