/* ================================================================
   THE GREAT COFFEE ORACLE — CSS
   Aesthetic: Windows 98 meets Geocities meets actual good taste
   ================================================================ */

:root {
  --green:    #00ff41;
  --lime:     #7fff00;
  --amber:    #ffb000;
  --red:      #ff3030;
  --cyan:     #00e5ff;
  --magenta:  #ff00ff;
  --white:    #e8e8e8;
  --bg:       #0a0a0a;
  --bg2:      #111111;
  --bg3:      #1a1a1a;
  --border:   #2a2a2a;
  --oracle:   #1a0a00;    /* dark brown bg for oracle messages */
  --user-bg:  #000d1a;   /* dark blue bg for user messages */
  --font-mono: 'Courier New', Courier, monospace;
  --font-comic: 'Comic Sans MS', 'Chalkboard SE', cursive;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: var(--font-mono);
  overflow-x: hidden;
}

/* ================================================================
   INTRO SCREEN
   ================================================================ */

#intro-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
}

.intro-container {
  max-width: 700px;
  width: 100%;
  padding: 2rem;
  text-align: center;
  position: relative;
  z-index: 1;
}

/* Animated starfield background */
.stars-bg {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(0,255,65,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 20%, rgba(0,229,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 70%, rgba(255,176,0,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 85%, rgba(0,255,65,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 50%, rgba(255,0,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 60%, rgba(0,255,65,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 90%, rgba(0,229,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 35%, rgba(255,176,0,0.3) 0%, transparent 100%);
  z-index: 0;
  pointer-events: none;
  animation: twinkle 4s infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* ASCII coffee cup */
.coffee-cup-ascii {
  color: var(--amber);
  font-size: 1.1rem;
  line-height: 1.3;
  margin-bottom: 0;
}

.coffee-cup-ascii pre {
  display: inline-block;
  text-align: left;
}

.steam {
  color: var(--amber);
  font-size: 1.8rem;
  letter-spacing: 8px;
  height: 30px;
  line-height: 30px;
  margin-top: -8px;
  margin-bottom: 8px;
}

.steam span {
  display: inline-block;
  animation: steam-rise 1.5s ease-in-out infinite;
}
.steam span:nth-child(1) { animation-delay: 0s; }
.steam span:nth-child(2) { animation-delay: 0.3s; }
.steam span:nth-child(3) { animation-delay: 0.6s; }

@keyframes steam-rise {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50%       { transform: translateY(-6px); opacity: 0.3; }
}

/* Title */
.title-blink {
  font-family: var(--font-comic);
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  color: var(--amber);
  text-shadow:
    0 0 10px var(--amber),
    0 0 30px rgba(255,176,0,0.5),
    0 0 60px rgba(255,176,0,0.2);
  animation: glow-pulse 2s ease-in-out infinite alternate;
  margin: 0.5rem 0;
  letter-spacing: 2px;
}

@keyframes glow-pulse {
  0%   { text-shadow: 0 0 10px var(--amber), 0 0 20px rgba(255,176,0,0.5); }
  100% { text-shadow: 0 0 20px var(--amber), 0 0 40px rgba(255,176,0,0.8), 0 0 80px rgba(255,176,0,0.3); }
}

.subtitle {
  font-size: 0.75rem;
  color: var(--green);
  letter-spacing: 3px;
  margin-bottom: 1rem;
  opacity: 0.8;
}

.separator {
  color: var(--amber);
  margin: 0.75rem 0;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Intro body text */
.intro-text {
  background: rgba(0, 255, 65, 0.05);
  border: 1px solid rgba(0,255,65,0.2);
  border-radius: 4px;
  padding: 1.25rem;
  margin: 1rem 0;
  text-align: left;
  line-height: 1.8;
  font-size: 0.9rem;
}

.intro-text p {
  margin-bottom: 0.5rem;
}

.counter-text {
  color: var(--cyan);
  font-weight: bold;
  text-shadow: 0 0 6px var(--cyan);
}

.warning-text {
  color: var(--red) !important;
  animation: flash 1.5s step-end infinite;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

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

/* Browser bar / marquee */
.browser-bar {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.4rem 0.75rem;
  margin: 0.75rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--green);
  overflow: hidden;
}

.browser-label {
  white-space: nowrap;
  color: var(--lime);
  flex-shrink: 0;
}

.retailer-marquee {
  flex: 1;
  overflow: hidden;
  color: var(--cyan);
}

.retailer-marquee marquee {
  font-size: 0.75rem;
}

/* CTA button */
.oracle-btn {
  display: inline-block;
  margin: 1rem auto;
  padding: 0.85rem 2.5rem;
  background: linear-gradient(135deg, #3d2000, #7a4000);
  border: 2px solid var(--amber);
  border-radius: 4px;
  color: var(--amber);
  font-family: var(--font-comic);
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  text-shadow: 0 0 8px var(--amber);
  box-shadow:
    0 0 15px rgba(255,176,0,0.3),
    inset 0 0 15px rgba(255,176,0,0.1);
  transition: all 0.2s ease;
  animation: btn-pulse 2s ease-in-out infinite alternate;
}

@keyframes btn-pulse {
  0%   { box-shadow: 0 0 10px rgba(255,176,0,0.3), inset 0 0 10px rgba(255,176,0,0.1); }
  100% { box-shadow: 0 0 25px rgba(255,176,0,0.7), inset 0 0 25px rgba(255,176,0,0.2); }
}

.oracle-btn:hover {
  background: linear-gradient(135deg, #7a4000, #c06000);
  transform: scale(1.03);
}

.oracle-btn:active {
  transform: scale(0.98);
}

.footer-text {
  font-size: 0.65rem;
  color: rgba(0,255,65,0.3);
  margin-top: 1.25rem;
  letter-spacing: 1px;
}

/* ================================================================
   CHAT SCREEN
   ================================================================ */

#chat-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}

.hidden {
  display: none !important;
}

/* Header */
.chat-header {
  background: linear-gradient(90deg, #1a0900, #2a1500, #1a0900);
  border-bottom: 2px solid var(--amber);
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 15px rgba(255,176,0,0.2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-cup {
  font-size: 1.3rem;
  animation: spin-slow 8s linear infinite;
  display: inline-block;
}

@keyframes spin-slow {
  0%   { transform: rotate(0deg); }
  10%  { transform: rotate(10deg); }
  20%  { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

.header-title {
  font-family: var(--font-comic);
  font-size: 1rem;
  color: var(--amber);
  font-weight: bold;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255,176,0,0.5);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.connection-status {
  font-size: 0.7rem;
  color: var(--green);
  animation: blink-slow 2s step-end infinite;
}

@keyframes blink-slow {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.reset-btn {
  background: transparent;
  border: 1px solid rgba(255,176,0,0.3);
  border-radius: 3px;
  color: rgba(255,176,0,0.6);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.reset-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(255,176,0,0.1);
}

/* ── Model toggle ── */
.model-toggle {
  display: flex;
  border: 1px solid rgba(255,176,0,0.25);
  border-radius: 4px;
  overflow: hidden;
}

.model-btn {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.model-btn--llama {
  color: rgba(0,255,65,0.5);
}
.model-btn--llama.active,
.model-btn--llama:hover {
  background: rgba(0,255,65,0.12);
  color: var(--green);
  text-shadow: 0 0 6px var(--green);
}

.model-btn--gpt {
  color: rgba(0,229,255,0.5);
  border-left: 1px solid rgba(255,176,0,0.2);
}
.model-btn--gpt.active,
.model-btn--gpt:hover {
  background: rgba(0,229,255,0.12);
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan);
}

/* Status bar */
.status-bar {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 0.3rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.68rem;
  color: rgba(0,255,65,0.6);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.status-bar .sep {
  color: rgba(0,255,65,0.2);
}

/* Chat container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.chat-container::-webkit-scrollbar {
  width: 6px;
}
.chat-container::-webkit-scrollbar-track {
  background: var(--bg3);
}
.chat-container::-webkit-scrollbar-thumb {
  background: rgba(255,176,0,0.4);
  border-radius: 3px;
}

/* Messages area */
.messages-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Individual message */
.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: msg-appear 0.3s ease-out;
}

@keyframes msg-appear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
}

.message.oracle {
  align-self: flex-start;
}

/* Message labels */
.message-label {
  font-size: 0.65rem;
  margin-bottom: 0.25rem;
  letter-spacing: 1px;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.message.user .message-label {
  justify-content: flex-end;
  color: var(--cyan);
}

.message.oracle .message-label {
  justify-content: flex-start;
  color: var(--amber);
}

/* Model tag pill inside oracle label */
.model-tag {
  font-size: 0.58rem;
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.model-tag--llama {
  background: rgba(0,255,65,0.12);
  color: var(--green);
  border: 1px solid rgba(0,255,65,0.25);
}

.model-tag--gpt4o {
  background: rgba(0,229,255,0.12);
  color: var(--cyan);
  border: 1px solid rgba(0,229,255,0.25);
}

/* GPT-4o oracle bubble gets a cyan left border accent */
.message.oracle.model-gpt4o .message-bubble {
  border-color: rgba(0,229,255,0.3);
  box-shadow: 0 0 8px rgba(0,229,255,0.08);
}

/* Thinking box model colouring */
.thinking-box.model-gpt4o .thinking-animation {
  color: var(--cyan);
}
.thinking-box.model-gpt4o .loading-fill {
  background: linear-gradient(90deg, var(--cyan), #7fff00);
}

/* Message bubbles */
.message-bubble {
  padding: 0.85rem 1rem;
  border-radius: 6px;
  line-height: 1.65;
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .message-bubble {
  background: var(--user-bg);
  border: 1px solid rgba(0,229,255,0.3);
  border-bottom-right-radius: 2px;
  color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,229,255,0.1);
}

.message.oracle .message-bubble {
  background: var(--oracle);
  border: 1px solid rgba(255,176,0,0.3);
  border-bottom-left-radius: 2px;
  color: var(--white);
  box-shadow: 0 0 8px rgba(255,176,0,0.1);
}

/* Special formatting inside oracle bubbles */
.message.oracle .message-bubble strong {
  color: var(--amber);
}

.message.oracle .message-bubble em {
  color: var(--lime);
  font-style: italic;
}

/* Thinking / loading box */
.thinking-box {
  align-self: flex-start;
  background: var(--oracle);
  border: 1px solid rgba(255,176,0,0.4);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  min-width: 320px;
  max-width: 500px;
  animation: msg-appear 0.3s ease-out;
}

.thinking-animation {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--amber);
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 1px;
  margin-bottom: 0.4rem;
}

.dots-anim {
  animation: dots 1.2s steps(4, end) infinite;
  letter-spacing: 2px;
}

@keyframes dots {
  0%   { content: '.  '; }
  25%  { content: '.. '; }
  50%  { content: '...'; }
  75%  { content: '   '; }
}

/* We fake it with opacity cycling instead */
.dots-anim span:nth-child(1) { animation: dot-appear 1.2s 0.0s infinite; }
.dots-anim span:nth-child(2) { animation: dot-appear 1.2s 0.4s infinite; }
.dots-anim span:nth-child(3) { animation: dot-appear 1.2s 0.8s infinite; }

@keyframes dot-appear {
  0%, 100% { opacity: 0; }
  50%       { opacity: 1; }
}

.thinking-sub {
  font-size: 0.7rem;
  color: rgba(255,176,0,0.5);
  margin-bottom: 0.6rem;
  animation: cycle-text 3s step-end infinite;
}

@keyframes cycle-text {
  0%   { opacity: 1; }
  90%  { opacity: 1; }
  95%  { opacity: 0; }
  100% { opacity: 1; }
}

/* Loading progress bar */
.loading-bar {
  height: 4px;
  background: rgba(255,176,0,0.15);
  border-radius: 2px;
  overflow: hidden;
}

.loading-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--lime));
  border-radius: 2px;
  animation: loading-sweep 2s ease-in-out infinite;
}

@keyframes loading-sweep {
  0%   { width: 0%;   margin-left: 0%; }
  50%  { width: 60%;  margin-left: 20%; }
  100% { width: 0%;   margin-left: 100%; }
}

/* Input area */
.input-area {
  background: var(--bg2);
  border-top: 2px solid rgba(255,176,0,0.3);
  padding: 0.75rem 1rem;
  flex-shrink: 0;
}

.input-container {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.user-textarea {
  flex: 1;
  background: var(--bg3);
  border: 1px solid rgba(0,229,255,0.3);
  border-radius: 4px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 0.6rem 0.8rem;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.user-textarea:focus {
  border-color: rgba(0,229,255,0.7);
  box-shadow: 0 0 8px rgba(0,229,255,0.15);
}

.user-textarea::placeholder {
  color: rgba(0,229,255,0.3);
  font-size: 0.82rem;
}

.send-btn {
  background: linear-gradient(135deg, #1a0900, #3a1800);
  border: 2px solid var(--amber);
  border-radius: 4px;
  color: var(--amber);
  font-family: var(--font-comic);
  font-size: 0.9rem;
  font-weight: bold;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(255,176,0,0.5);
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #3a1800, #6a3000);
  box-shadow: 0 0 12px rgba(255,176,0,0.4);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.input-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.65rem;
  color: rgba(0,255,65,0.3);
  margin-top: 0.35rem;
  padding: 0 0.1rem;
}

.input-meta .sep {
  color: rgba(0,255,65,0.15);
}

/* Page footer */
.page-footer {
  background: #050505;
  border-top: 1px solid var(--border);
  padding: 0.3rem 1rem;
  text-align: center;
  font-size: 0.65rem;
  color: rgba(0,255,65,0.25);
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

/* ================================================================
   WELCOME MESSAGE (first oracle message)
   ================================================================ */

.welcome-message .message-bubble {
  border-color: rgba(255,176,0,0.5) !important;
  box-shadow:
    0 0 15px rgba(255,176,0,0.15),
    inset 0 0 15px rgba(255,176,0,0.03) !important;
}

/* ================================================================
   ERROR STATE
   ================================================================ */

.message.error .message-bubble {
  background: #1a0000;
  border-color: rgba(255,48,48,0.5);
  color: var(--red);
}

/* ================================================================
   SYSTEM MESSAGES
   ================================================================ */

.message.system {
  align-self: center;
}

.message.system .message-bubble {
  background: rgba(0,229,255,0.05);
  border: 1px dashed rgba(0,229,255,0.2);
  color: rgba(0,229,255,0.6);
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
  border-radius: 12px;
  text-align: center;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 600px) {
  .title-blink {
    font-size: 1.3rem;
  }

  .message {
    max-width: 95%;
  }

  .thinking-box {
    min-width: 260px;
  }

  .oracle-btn {
    font-size: 0.95rem;
    padding: 0.75rem 1.5rem;
  }

  .header-title {
    font-size: 0.8rem;
    letter-spacing: 1px;
  }
}
