/* =====================================================
   John Zertuche · Personal Website
   Frosted glass: cool light, soft color, no boxes
   ===================================================== */

:root {
  /* Ground */
  --bg: #F2F3F8;
  --bg-deep: #E2E5F1;

  /* Ink */
  --ink: #15171C;
  --ink-soft: #4A4F5E;
  --ink-mute: #8B90A1;

  /* Glass */
  --glass: rgba(255, 255, 255, 0.42);
  --glass-strong: rgba(255, 255, 255, 0.62);
  --glass-edge: rgba(255, 255, 255, 0.9);
  --glass-line: rgba(255, 255, 255, 0.55);
  --glass-shadow: 0 1px 1px rgba(21, 23, 28, 0.03), 0 20px 50px -24px rgba(56, 68, 140, 0.28);

  /* Color */
  --accent: #5868F5;
  --accent-soft: #AEB8FF;

  /* Type */
  --font-display: 'Geist Mono', ui-monospace, 'SF Mono', monospace;
  --font-body: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  background: var(--bg);
}

/* body stays transparent: the fixed .aura sits behind it at z-index -1,
   and an opaque body would paint over it. The ground color lives on html. */
body {
  font-family: var(--font-body);
  background: transparent;
  color: var(--ink);
  line-height: 1.6;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

::selection {
  background: var(--accent);
  color: #fff;
}

a {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 0% 1px;
  background-position: 0 100%;
  transition: background-size 200ms var(--ease);
}

a:hover, a:focus-visible {
  background-size: 100% 1px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* =====================================================
   Aura: one soft blue haze rising from below, slowly breathing
   ===================================================== */

.aura {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
  background: #F2F3F8;
}

.aura::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -62vh;
  width: 130vw;
  height: 115vh;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(120, 138, 250, 0.34), rgba(120, 138, 250, 0));
  animation: mist 12s ease-in-out infinite;
}

@keyframes mist {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 1; }
  50% { transform: translateX(-50%) scale(1.08); opacity: 0.75; }
}

/* Binary ripple canvas (js/ripple.js): above the aura, behind everything else. */
.ripple-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* Easter egg pile (js/egg.js): above the page, below the pinned prompt. */
.egg-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

/* =====================================================
   Layout: content floats on the aura, no bounding frame
   ===================================================== */

.ask {
  min-height: 100svh;
  padding: clamp(0.75rem, 3vw, 2.5rem);
  display: flex;
}

.frame {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 6vh, 4.5rem) clamp(0.25rem, 3vw, 2rem);
}

.ask-inner {
  position: relative;
  min-width: 0;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
}

/* =====================================================
   Intro
   ===================================================== */

.ask-intro {
  text-align: center;
}

.ask-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.035em;
  color: var(--ink);
  transition: font-size 450ms var(--ease);
}

.ask-title .hl {
  padding: 0 0.08em;
  margin: 0 -0.04em;
  background: linear-gradient(transparent 58%, rgba(88, 104, 245, 0.22) 58%, rgba(88, 104, 245, 0.22) 92%, transparent 92%);
}

.ask-sub {
  display: flex;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  font-family: var(--font-mono);
  font-size: clamp(0.98rem, 1.6vw, 1.12rem);
  color: var(--ink-soft);
  margin: 1.1rem 0 2.75rem;
}

.ask-sub-line {
  display: inline-flex;
  flex: none;
  align-items: baseline;
  gap: 0.6ch;
  margin-inline: auto;
}

/* The rotating phrase crossfades; on wide screens its width glides so
   "Ask about" slides smoothly instead of jumping. */
.rotator {
  display: inline-block;
  vertical-align: bottom;
  white-space: nowrap;
  overflow: hidden;
  color: var(--ink);
  font-weight: 500;
  transition: opacity 450ms ease, width 650ms var(--ease);
}

.rotator br { display: none; }

.rotator-measure {
  position: fixed;
  left: -10000px;
  top: 0;
  width: max-content;
  visibility: hidden;
  pointer-events: none;
}


/* =====================================================
   Prompt box
   ===================================================== */

.ask-form {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.55rem 0.55rem 0.55rem 1.35rem;
  background: var(--glass);
  border: 1.5px solid var(--glass-edge);
  border-radius: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--glass-shadow);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  transition: box-shadow 250ms var(--ease), background 250ms var(--ease);
}

/* Edge light: the glass rim catches light near the cursor (position set in chat.js). */
.ask-form::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  padding: 1.5px;
  background: radial-gradient(180px circle at var(--mx, 50%) var(--my, -200px), rgba(255, 255, 255, 1), rgba(160, 172, 255, 0.55) 35%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: var(--edge, 0);
  transition: opacity 300ms ease;
  pointer-events: none;
}

.ask-form::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, -200px), rgba(255, 255, 255, 0.28), transparent 65%);
  opacity: var(--edge, 0);
  transition: opacity 300ms ease;
  pointer-events: none;
}

.ask-form:focus-within {
  background: var(--glass-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 0 0 4px rgba(88, 104, 245, 0.12),
    0 24px 60px -24px rgba(56, 68, 140, 0.38);
}

.ask-form textarea {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--ink);
  max-height: 180px;
}

.ask-form textarea::placeholder {
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ask-send {
  position: relative;
  z-index: 1;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #2A2D36, #121419);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 22px -10px rgba(21, 23, 28, 0.7);
  transition: transform 160ms var(--ease), opacity 160ms ease, box-shadow 160ms ease;
}

.ask-send:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 14px 26px -10px rgba(21, 23, 28, 0.75);
}

.ask-send svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ask-form.is-busy .ask-send {
  opacity: 0.35;
  pointer-events: none;
}

/* =====================================================
   Ticker of suggested prompts
   ===================================================== */

.ask-ticker {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1.4rem;
  overflow: hidden;
}

.ticker-row {
  overflow: hidden;
  padding: 0.2rem 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

/* Each row is tripled in JS; sliding by one third loops seamlessly. */
.ask-chips {
  list-style: none;
  display: flex;
  width: max-content;
  animation: ticker 90s linear infinite;
  will-change: transform;          /* own GPU layer: no per-frame re-raster jitter */
  backface-visibility: hidden;
}

.ask-chips.is-reverse {
  animation-direction: reverse;
}

.ask-chips li {
  flex: none;
  padding-right: 0.55rem;
}

.ticker-row:hover .ask-chips,
.ticker-row:focus-within .ask-chips {
  animation-play-state: paused;
}

@keyframes ticker {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(calc(-100% / 3), 0, 0); }
}

.ask-chips button {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-soft);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 6px 16px -10px rgba(56, 68, 140, 0.3);
  transition: background 180ms ease, color 180ms ease, transform 180ms var(--ease);
}

.ask-chips button:hover,
.ask-chips button:focus-visible {
  background: #15171C;
  color: #fff;
  transform: translateY(-1px);
}

/* =====================================================
   Conversation
   ===================================================== */

.ask-thread {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.msg {
  max-width: 100%;
  line-height: 1.65;
  animation: rise 420ms var(--ease) both;
}

.msg-user {
  align-self: flex-end;
  max-width: 82%;
  background: linear-gradient(180deg, #23262F, #15171C);
  color: #F4F5FA;
  padding: 0.7rem 1.05rem;
  border-radius: 18px 18px 6px 18px;
  white-space: pre-wrap;
  box-shadow: 0 12px 28px -16px rgba(21, 23, 28, 0.6);
}

.msg-assistant {
  align-self: flex-start;
  max-width: 100%;
  color: var(--ink);
  padding: 0.25rem 0.1rem;
}

.msg-assistant p + p,
.msg-assistant p + ul,
.msg-assistant ul + p { margin-top: 0.7rem; }

.msg-assistant ul { padding-left: 1.15rem; }

.msg-assistant li + li { margin-top: 0.3rem; }

.msg-assistant li::marker { color: var(--accent); }

.msg-assistant strong { font-weight: 600; }

.typing {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: linear-gradient(90deg, var(--ink-mute) 0%, var(--ink-mute) 35%, var(--accent) 50%, var(--ink-mute) 65%, var(--ink-mute) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.8s linear infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -150% 0; }
}

/* Follow-up questions offered after each answer. */
.followups {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  margin-top: -0.25rem;
  animation: rise 420ms 120ms var(--ease) both;
}

.followups button {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-align: left;
  color: var(--ink-soft);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 6px 16px -10px rgba(56, 68, 140, 0.3);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background 180ms ease, color 180ms ease, transform 180ms var(--ease);
}

.followups button::before {
  content: "↳ ";
  color: var(--accent);
}

.followups button:hover,
.followups button:focus-visible {
  background: #15171C;
  color: #fff;
  transform: translateY(-1px);
}

/* Preview cards for John's sites, with their share images. */
.preview-card {
  display: flex;
  align-items: stretch;
  max-width: 34rem;
  overflow: hidden;
  color: var(--ink);
  background: var(--glass-strong);
  background-image: none;
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--glass-shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease);
  animation: rise 520ms 80ms var(--ease) both;
}

.preview-card:hover,
.preview-card:focus-visible {
  background-size: auto;
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 24px 48px -24px rgba(56, 68, 140, 0.4);
}

.preview-card img {
  flex: none;
  width: 11.5rem;
  object-fit: cover;
  background: #E6E8F2;
}

.pc-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  min-width: 0;
}

.pc-text strong {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.pc-text span {
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.pc-text small {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-mute);
}

@media (max-width: 700px) {
  .preview-card {
    flex-direction: column;
  }

  .preview-card img {
    width: 100%;
    aspect-ratio: 1.91;
  }
}

/* Hand-off to X when someone wants to get in touch. */
.x-cta {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.15rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #fff;
  background: linear-gradient(180deg, #2A2D36, #121419);
  background-size: auto;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 14px 28px -14px rgba(21, 23, 28, 0.7);
  transition: transform 180ms var(--ease), box-shadow 180ms ease;
  animation: rise 420ms 120ms var(--ease) both;
}

.x-cta:hover,
.x-cta:focus-visible {
  background-size: auto;
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 18px 32px -14px rgba(21, 23, 28, 0.75);
}

.x-cta svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
}

/* =====================================================
   Entrance (js/boot.js adds .is-ready once fonts load)
   The haze blooms up, the headline settles in word by word, the highlighter
   swipes across "John", then the line, prompt box, and ticker follow.
   Without JS nothing is hidden.
   ===================================================== */

.js:not(.is-ready) .aura,
.js:not(.is-ready) .ask-title .w,
.js:not(.is-ready) .ask-sub,
.js:not(.is-ready) .ask-form,
.js:not(.is-ready) .ticker-row,
.js:not(.is-ready) .ask-ticker {
  opacity: 0;
}

.is-ready .aura { animation: bloom 1600ms var(--ease) backwards; }
.is-ready .ask-title .w {
  display: inline-block;
  animation: settle 900ms var(--ease) backwards;
}
.is-ready .ask-title .w:nth-child(1) { animation-delay: 120ms; }
.is-ready .ask-title .w:nth-child(2) { animation-delay: 220ms; }
.is-ready .ask-title .w:nth-child(3) { animation-delay: 320ms; }
.is-ready .ask-title .hl {
  background-repeat: no-repeat;
  animation: swipe 700ms 820ms cubic-bezier(0.65, 0, 0.35, 1) backwards;
}
.is-ready .ask-sub { animation: rise 800ms 620ms var(--ease) backwards; }
.is-ready .ask-form { animation: lift 900ms 760ms var(--ease) backwards; }
.is-ready .ticker-row { animation: fade 1100ms var(--ease) backwards; }
.is-ready .ticker-row:nth-child(1) { animation-delay: 980ms; }
.is-ready .ticker-row:nth-child(2) { animation-delay: 1120ms; }

@keyframes bloom {
  from { opacity: 0; transform: translateY(6vh); }
  to { opacity: 1; transform: none; }
}

@keyframes settle {
  from { opacity: 0; transform: translateY(0.35em); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes swipe {
  from { background-size: 0% 100%; }
  to { background-size: 100% 100%; }
}

@keyframes lift {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Start over: only while chatting, pinned to the top as the thread scrolls. */
.ask-back {
  display: none;
  position: sticky;
  top: max(1rem, env(safe-area-inset-top));
  z-index: 6;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.85rem 0.5rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--glass-edge);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), var(--glass-shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: background 180ms ease, color 180ms ease, transform 180ms var(--ease);
}

.ask-back:hover,
.ask-back:focus-visible {
  background: #15171C;
  color: #fff;
  transform: translateX(-2px);
}

.ask-back svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.is-chatting .ask-back {
  display: inline-flex;
}

/* While chatting, messages scroll under a soft fade at the top so the pinned
   Start over button never sits on top of text. */
.is-chatting::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: calc(4.25rem + env(safe-area-inset-top));
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(#F2F3F8 55%, rgba(242, 243, 248, 0));
}

.is-chatting .ask-title {
  cursor: pointer;
}

/* =====================================================
   Chatting: intro compacts, thread fills, prompt docks
   ===================================================== */

.is-chatting .frame {
  align-items: stretch;
  padding-bottom: 0;
}

/* Chat fills the screen: the thread grows and the prompt box sits at the bottom. */
.is-chatting .ask-inner {
  display: flex;
  flex-direction: column;
}

.is-chatting .ask-form {
  margin-top: 0;
}

/* Text scrolls up behind the pinned prompt and fades out above it. */
.is-chatting::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(max(clamp(1.25rem, 5vh, 3.25rem), env(safe-area-inset-bottom)) + var(--prompt-height, 4rem) + 2.5rem);
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(rgba(242, 243, 248, 0), #F2F3F8 55%);
}

.is-chatting .ask-back {
  align-self: flex-start;
}

.is-chatting .ask-intro {
  margin-bottom: 1.75rem;
}

.is-chatting .ask-title {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.is-chatting .ask-sub,
.is-chatting .ask-ticker {
  display: none;
}

.is-chatting .ask-thread {
  flex: 1;
  padding-bottom: calc(max(clamp(1.25rem, 5vh, 3.25rem), env(safe-area-inset-bottom)) + var(--prompt-height, 4rem) + 2rem);
}

.is-chatting .ask-form {
  position: fixed;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: min(46rem, calc(100% - 2 * clamp(0.75rem, 3vw, 2.5rem) - 2 * clamp(0.25rem, 3vw, 2rem)));
  bottom: max(clamp(1.25rem, 5vh, 3.25rem), env(safe-area-inset-bottom));
  z-index: 6;
  background: rgba(255, 255, 255, 0.72);
}

.is-chatting .ask-inner {
  padding-bottom: 1.25rem;
}

/* =====================================================
   Small screens
   ===================================================== */

@media (max-width: 700px) {
  /* Room for the longest rotating phrase, so the prompt box never jumps. */
  .ask-sub {
    font-size: 0.95rem;
  }


      .msg-user {
    max-width: 92%;
  }

  .is-chatting .frame {
    padding-top: 1.25rem;
  }
}

/* =====================================================
   Reduced motion: everything holds still
   ===================================================== */

@media (prefers-reduced-motion: reduce) {
  .aura::before,
  .typing,
  .msg,
  .ask-title,
  .ask-sub,
  .is-ready .aura,
  .is-ready .ask-title .w,
  .is-ready .ask-title .hl,
  .is-ready .ask-sub,
  .is-ready .ask-form,
  .is-ready .ticker-row {
    animation: none;
  }

  .ticker-row {
    -webkit-mask-image: none;
    mask-image: none;
  }

  .ask-chips {
    animation: none;
    width: auto;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 0.5rem;
  }

  .ask-chips [aria-hidden="true"] {
    display: none;
  }

  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}

.msg-assistant a {
  overflow-wrap: anywhere;
}

/* Rapid clicks (the emoji easter egg) should never highlight the headline. */
.ask-intro,
.ask-ticker,
.ask-back {
  -webkit-user-select: none;
  user-select: none;
}
