/* Stanford Brand Palette */
:root {
  --cardinal-red: #8C1515;
  --stanford-black: #2E2D29;
  --cool-grey: #53565A;
  --cream: #F4F1E9;
  --dark-bg: #1a1a1a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Source Sans 3', sans-serif;
  background: var(--dark-bg);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* -------- Screens: base layout system -------- */
.screen {
  display: none;
  position: absolute;
  inset: 0;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.screen.active { display: grid; }

/* -------- IDLE SCREEN: 3-row grid, robot on top, tagline, button --------
   Ensures the button is always visible on any viewport. */
#idle-screen {
  grid-template-rows: 1fr auto auto 1fr;
  grid-template-areas:
    "robot"
    "tagline"
    "action"
    ".";
  align-items: center;
  justify-items: center;
  padding: 24px 24px calc(24px + var(--safe-bottom)) 24px;
  gap: 16px;
}

#idle-screen .robot-container {
  grid-area: robot;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

#idle-screen .robot {
  max-height: min(45vh, 380px);
  max-width: min(65vw, 320px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.tagline {
  grid-area: tagline;
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: clamp(20px, 4vw, 32px);
  color: var(--cream);
  opacity: 0.9;
  text-align: center;
  line-height: 1.2;
  max-width: 90%;
}

.tagline small {
  display: block;
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 400;
  font-size: clamp(14px, 2.4vw, 18px);
  opacity: 0.65;
  margin-top: 6px;
}

#idle-screen .action {
  grid-area: action;
  display: flex;
  justify-content: center;
  width: 100%;
}

/* -------- CALL SCREEN: robot up top small, transcript middle, hang-up bottom -------- */
#call-screen {
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "robot"
    "transcript"
    "action";
  padding: 16px 16px calc(16px + var(--safe-bottom)) 16px;
  gap: 12px;
}

#call-screen .robot-container {
  grid-area: robot;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

#call-screen .robot {
  max-height: 18vh;
  max-width: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.indicator {
  font-size: 15px;
  font-weight: 600;
  color: var(--cream);
  opacity: 0.85;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.indicator.listening::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--cardinal-red);
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
  animation: pulse 1.5s ease-in-out infinite;
}

.indicator.thinking { color: var(--cool-grey); }
.indicator.speaking { color: var(--cardinal-red); }

.transcript-panel {
  grid-area: transcript;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.transcript-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: clamp(16px, 2.4vw, 20px);
  line-height: 1.4;
  -webkit-overflow-scrolling: touch;
}

.transcript-log:empty::before {
  content: "Waiting for you to speak…";
  color: var(--cool-grey);
  font-style: italic;
  align-self: center;
  margin: auto;
  opacity: 0.7;
}

.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 92%;
  word-wrap: break-word;
}

.bubble-user {
  align-self: flex-end;
  background: var(--cardinal-red);
  color: var(--cream);
}

.bubble-bot {
  align-self: flex-start;
  background: var(--cream);
  color: var(--stanford-black);
}

.bubble small {
  display: block;
  font-size: 11px;
  opacity: 0.6;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

#call-screen .action {
  grid-area: action;
  display: flex;
  justify-content: center;
  padding-bottom: 4px;
}

/* -------- Message / error screens -------- */
#permission-screen,
#ratelimit-screen,
#error-screen,
#silence-screen {
  grid-template-rows: 1fr auto 1fr;
  place-items: center;
  padding: 24px;
}

.message-container {
  grid-row: 2;
  max-width: 560px;
  text-align: center;
}

.message-container h1 {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: clamp(28px, 5vw, 40px);
  margin-bottom: 12px;
  color: var(--cream);
}

.message-container p {
  font-size: clamp(16px, 2.4vw, 20px);
  line-height: 1.5;
  margin-bottom: 12px;
  color: var(--cream);
  opacity: 0.9;
}

.message-container .instruction {
  font-size: clamp(14px, 2vw, 16px);
  color: var(--cool-grey);
  margin-bottom: 22px;
}

.message-container button {
  margin: 6px;
}

/* -------- Buttons -------- */
button {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.primary-button {
  background: var(--cardinal-red);
  color: white;
  font-size: clamp(20px, 3.2vw, 28px);
  padding: 22px 56px;
  min-height: 72px;
  min-width: 240px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(140, 21, 21, 0.45);
  letter-spacing: 0.5px;
}

.primary-button:hover { background: #a01818; }
.primary-button:active {
  transform: scale(0.97);
  box-shadow: 0 4px 12px rgba(140, 21, 21, 0.4);
}

/* Special: idle "Pick up" is the hero of the screen */
#idle-screen .primary-button {
  font-size: clamp(24px, 4vw, 32px);
  padding: 26px 72px;
  min-height: 80px;
  min-width: 260px;
}

.secondary-button {
  background: var(--cool-grey);
  color: white;
  font-size: clamp(16px, 2.6vw, 20px);
  padding: 16px 36px;
  min-height: 56px;
  min-width: 180px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(83, 86, 90, 0.3);
}

.secondary-button:hover { background: #6a6d71; }
.secondary-button:active { transform: scale(0.97); }

/* -------- Robot animations -------- */
.robot { display: block; }

.robot.breathing {
  animation: breathe 4s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes breathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50%      { transform: scale(1.03) translateY(-6px); }
}

.robot.listening {
  animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(140, 21, 21, 0.4)); }
  50%      { filter: drop-shadow(0 0 28px rgba(140, 21, 21, 0.8)); }
}

.robot.speaking {
  animation: speakBounce 0.5s ease-in-out infinite;
}

@keyframes speakBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* -------- Global "End call" button (top-right, non-idle states) -------- */
.global-hangup-btn {
  position: fixed;
  top: calc(16px + var(--safe-top));
  right: 16px;
  z-index: 1000;
  background: var(--cardinal-red);
  color: var(--cream);
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  min-height: 44px;
  min-width: 88px;
}

.global-hangup-btn:active { transform: scale(0.96); }
.global-hangup-btn.hidden { display: none; }

/* -------- Install hint (Safari, non-standalone) -------- */
#install-hint {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 14px calc(10px + var(--safe-bottom)) 14px;
  background: var(--cream);
  color: var(--stanford-black);
  font-size: 13px;
  text-align: center;
  z-index: 900;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.3);
}

/* -------- Accessibility -------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* -------- Landscape iPad: side-by-side robot + transcript on call screen -------- */
@media (min-width: 900px) and (orientation: landscape) {
  #call-screen {
    grid-template-rows: 1fr auto;
    grid-template-columns: 260px 1fr;
    grid-template-areas:
      "robot transcript"
      "action action";
    gap: 20px;
    padding: 24px;
  }
  #call-screen .robot-container { align-self: center; }
  #call-screen .robot { max-height: 40vh; max-width: 240px; }
}
</content>
</invoke>