/* Brand palette — aligned with sanctumtools.com */
:root {
  --primary-purple: #9932a8;
  --soft-purple: #b565c7;
  --light-purple: #d8b5e3;
  --warm-beige: #f5f1e8;
  --bg: #f5f1e8;
  --fg: #000000;
  --muted: #000000;
  --accent: #9932a8;
  --accent-hover: #7d2a89;
  --card: #ffffff;
  --border: #e7e1d3;
  --crisis-red: #dc2626;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-weight: 500;
  line-height: 1.7;
  position: relative;
  min-height: 100vh;
}

/* Text that sits directly on the doodled body background needs extra weight
   to read against the dark watermark lines. Cards (with white bg) override
   this back to a normal weight via their own rules. */
main p, main li { font-weight: 500; }

/* Doodle background removed — clean warm-beige page. */

/* Sign-in intro panel — first impression for unauthed visitors */
.signin-intro {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.signin-intro h2 {
  margin: 0 0 0.5rem;
  font-size: 1.7rem;
  color: var(--fg);
}
.signin-intro .lede {
  font-size: 1.15rem;
  color: var(--fg);
  margin: 0 0 1rem;
  font-weight: 600;
}
.signin-intro p { margin: 0 0 0.85rem; }
.signin-intro p:last-child { margin-bottom: 0; }
.signin-intro .cta-line {
  font-size: 1.05rem;
  color: var(--fg);
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
  margin-top: 0.25rem;
}

/* Home welcome panel + JC quote */
.home-welcome {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 0 0 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.home-welcome h2 {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
  color: var(--fg);
}
.home-welcome p { margin: 0 0 0.75rem; }
.home-welcome a { font-weight: 600; }

.home-quote {
  margin: 1rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--border);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--fg);
}
.home-quote p { margin: 0 0 0.4rem; }
.home-quote cite {
  font-style: normal;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

/* Hero image used at top of each gated page (about, built, memoir, etc.). */
.page-hero-image {
  width: 100%;
  height: 320px;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 0 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
.page-hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

main { position: relative; z-index: 1; }
header { position: relative; z-index: 100; }
#chat-panel { z-index: 50; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--soft-purple) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(153, 50, 168, 0.15);
}
header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
header h1 a { color: inherit; text-decoration: none; }

/* Site nav (header toggles between Home / About / Built / Resume) */
.site-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.site-nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.site-nav a:hover { background: rgba(255, 255, 255, 0.15); color: white; }
.site-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.22);
  color: white;
}

/* Default: nav hidden. Pages set data-authed on body once user is signed in. */
.site-nav { display: none; }
body[data-authed] .site-nav { display: flex; }

/* Hamburger toggle — hidden on desktop, shown on mobile */
.nav-toggle {
  display: none;
  background: transparent;
  border: 0;
  padding: 0.5rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: white;
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.15); }
.nav-toggle .bars {
  display: block;
  position: relative;
  width: 22px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: background 0.15s;
}
.nav-toggle .bars::before,
.nav-toggle .bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 22px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: transform 0.2s;
}
.nav-toggle .bars::before { top: -7px; }
.nav-toggle .bars::after  { top:  7px; }

body.nav-open .nav-toggle .bars { background: transparent; }
body.nav-open .nav-toggle .bars::before { transform: translateY(7px) rotate(45deg); }
body.nav-open .nav-toggle .bars::after  { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 720px) {
  header {
    padding: 0.85rem 1rem;
    gap: 0.5rem;
  }
  body[data-authed] .nav-toggle { display: inline-flex; }

  /* Mobile drawer: hide horizontal nav until opened */
  body[data-authed] .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--soft-purple) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    z-index: 50;
  }
  body[data-authed].nav-open .site-nav { display: flex; }

  .site-nav a {
    padding: 0.9rem 1.25rem;
    border-radius: 0;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .site-nav a:last-child { border-bottom: 0; }
  .site-nav a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.18);
  }
}

/* Gated subpages hide main content until auth-gate.js confirms sign-in. */
body[data-gated] main { visibility: hidden; }
#user-bar {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
#user-bar button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.8rem;
  transition: background 0.15s;
}
#user-bar button:hover {
  background: rgba(255, 255, 255, 0.25);
}

main {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

#signin-form { display: flex; gap: 0.5rem; margin: 1rem 0; }
#signin-form input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: white;
  transition: border-color 0.15s;
}
#signin-form input:focus {
  outline: none;
  border-color: var(--primary-purple);
  box-shadow: 0 0 0 3px rgba(153, 50, 168, 0.15);
}
#signin-form button, #back-btn {
  padding: 0.7rem 1.25rem;
  background: var(--primary-purple);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s;
}
#signin-form button:hover { background: var(--accent-hover); }
#back-btn {
  background: transparent;
  color: var(--primary-purple);
  padding: 0.4rem 0;
  margin-bottom: 1rem;
  font-weight: 600;
}
#back-btn:hover { color: var(--accent-hover); background: transparent; }

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.post-card:hover {
  border-color: var(--soft-purple);
  box-shadow: 0 4px 12px rgba(153, 50, 168, 0.1);
  transform: translateY(-1px);
}
.post-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  color: var(--fg);
}
.post-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.post-card .tags {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--primary-purple);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#post-detail {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
#post-detail h2 { margin-top: 0; color: var(--fg); }
#post-detail .body { white-space: pre-wrap; }

a { color: var(--primary-purple); }
a:hover { color: var(--accent-hover); }

#chat-panel {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 360px;
  max-height: 500px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(153, 50, 168, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.18s, max-height 0.18s, border-radius 0.18s;
}

/* Minimized = pill shape, just wide enough for "Ask" + expand button */
#chat-panel.minimized {
  width: auto;
  max-height: none;
  border-radius: 999px;
}
#chat-panel.minimized #chat-body { display: none; }
#chat-panel.minimized #chat-header {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  gap: 0.5rem;
}

/* On phones, default to the minimized pill (unless explicitly .expanded) */
@media (max-width: 600px) {
  #chat-panel:not(.expanded) {
    width: auto;
    max-height: none;
    border-radius: 999px;
  }
  #chat-panel:not(.expanded) #chat-body { display: none; }
  #chat-panel:not(.expanded) #chat-header {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    gap: 0.5rem;
  }
  #chat-panel.expanded {
    width: calc(100vw - 2rem);
    left: 1rem;
    max-height: 70vh;
  }
}

#chat-header {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--soft-purple) 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
}
#chat-header button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
}
#chat-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  font-size: 0.92rem;
  background: #fafafa;
}
.msg { margin-bottom: 0.85rem; }
.msg.user { text-align: right; }
.msg .bubble {
  display: inline-block;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  max-width: 85%;
  white-space: pre-wrap;
  line-height: 1.5;
}
.msg.user .bubble {
  background: var(--primary-purple);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg.assistant .bubble {
  background: white;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg .bubble a { color: inherit; text-decoration: underline; }
.msg.user .bubble a { color: white; }

#chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem;
  border-top: 1px solid var(--border);
  background: white;
}
#chat-form input {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}
#chat-form input:focus {
  outline: none;
  border-color: var(--primary-purple);
}
#chat-form button {
  padding: 0.5rem 0.9rem;
  background: var(--primary-purple);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}
#chat-form button:hover { background: var(--accent-hover); }

/* Site footer */
.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 2rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: #555;
  background: rgba(255, 255, 255, 0.4);
}
.site-footer p { margin: 0.25rem 0; }
.site-footer a {
  color: var(--primary-purple);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }
@media (max-width: 720px) {
  .site-footer { padding: 1.25rem 1rem 1.5rem; }
}
