/* ================================================
   Python Together — style.css
   "Warm study room at golden hour meets Duolingo's
    playful energy"
   ================================================ */

/* ------------------------------------------------
   0. CSS Custom Properties
   ------------------------------------------------ */
:root {
  /* Backgrounds: warm earth tones */
  --bg-deep:        #1a1714;
  --bg-main:        #21201c;
  --bg-panel:       #2a2824;
  --bg-editor:      #1e1d19;
  --bg-chat:        #25231f;
  --bg-hover:       #33312b;
  --bg-input:       #1b1a16;

  /* Accent: warm amber/gold */
  --accent:         #d4a853;
  --accent-soft:    #c49a4240;
  --accent-glow:    #d4a85318;
  --accent-bright:  #e8c06a;

  /* Text */
  --text-primary:   #e8e2d6;
  --text-secondary: #a39e90;
  --text-muted:     #6b665a;
  --text-code:      #d4cfc3;

  /* Player colors — Vikas = green, Ishika = blue */
  --vikas-color:    #7eb88c;
  --vikas-bg:       #7eb88c18;
  --vikas-border:   #7eb88c30;
  --vikas-bubble:   #2d3530;
  --vikas-bubble-border: #3d4a3e;

  --ishika-color:   #8ba7cb;
  --ishika-bg:      #8ba7cb18;
  --ishika-border:  #8ba7cb30;
  --ishika-bubble:  #2b3040;
  --ishika-bubble-border: #3a4055;

  /* System */
  --error:          #d4736e;
  --error-bg:       #d4736e18;
  --success:        #7eb88c;
  --border:         #3a3733;
  --border-subtle:  #2f2d29;

  /* Typography */
  --font-display:   'Bricolage Grotesque', sans-serif;
  --font-body:      'DM Sans', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;

  /* Spacing & Radius */
  --radius-sm:      8px;
  --radius-md:      16px;
  --radius-lg:      24px;
  --radius-xl:      32px;

  /* Shadows — warm-tinted offset */
  --shadow-sm:      3px 3px 0px #0d0c0a;
  --shadow-md:      5px 5px 0px #0d0c0a;
  --shadow-lg:      8px 8px 0px #0d0c0a;
  --border-width:   2.5px;
}

/* ------------------------------------------------
   1. Reset & Base
   ------------------------------------------------ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Warm grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px;
  opacity: 0.035;
  pointer-events: none;
  z-index: 9999;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-bright);
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--accent-bright);
  background: var(--accent-glow);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------
   2. Screen Management
   ------------------------------------------------ */
.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.35s ease;
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------
   3. Loading Screen
   ------------------------------------------------ */
#screen-loading {
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
}

.loading-content {
  text-align: center;
  animation: bounceIn 0.6s ease;
}

.loading-icon {
  font-size: 56px;
  margin-bottom: 16px;
  animation: loadingPulse 2s ease-in-out infinite;
}

.loading-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 42px;
  color: var(--text-primary);
  letter-spacing: -1px;
  margin-bottom: 8px;
}

.loading-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 32px;
}

.loading-bar {
  width: 260px;
  height: 8px;
  background: var(--bg-panel);
  border-radius: 100px;
  overflow: hidden;
  margin: 0 auto;
  border: 1.5px solid var(--border-subtle);
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  border-radius: 100px;
  transition: width 0.4s ease;
  animation: loadingPulse 1.8s ease-in-out infinite;
}

/* ------------------------------------------------
   4. Identity Screen
   ------------------------------------------------ */
#screen-identity {
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
}

.identity-content {
  text-align: center;
  animation: slideUp 0.5s ease;
}

.identity-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 56px;
  color: var(--text-primary);
  letter-spacing: -1.5px;
  margin-bottom: 8px;
}

.identity-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 48px;
}

.identity-buttons {
  display: flex;
  gap: 28px;
  justify-content: center;
}

.identity-btn {
  width: 220px;
  height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.identity-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.identity-btn:active {
  transform: translateY(2px);
  box-shadow: 1px 1px 0px #0d0c0a;
}

.identity-emoji {
  font-size: 40px;
  display: block;
}

.identity-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
}

/* Vikas button */
.identity-btn-vikas:hover {
  border-color: var(--vikas-color);
  box-shadow: var(--shadow-lg), 0 0 24px #7eb88c15;
}

.identity-btn-vikas:hover .identity-name {
  color: var(--vikas-color);
}

/* Ishika button */
.identity-btn-ishika:hover {
  border-color: var(--ishika-color);
  box-shadow: var(--shadow-lg), 0 0 24px #8ba7cb15;
}

.identity-btn-ishika:hover .identity-name {
  color: var(--ishika-color);
}

/* Switch identity link */
.identity-switch-link {
  margin-top: 32px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ------------------------------------------------
   5. Conversations Screen
   ------------------------------------------------ */
#screen-conversations {
  background: var(--bg-deep);
}

/* -- Header -- */
.conversations-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1.5px solid var(--border-subtle);
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 24px;
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: var(--text-primary);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.partner-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover);
  padding: 5px 14px 5px 10px;
  border-radius: 100px;
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulseGlow 2s ease-in-out infinite;
  color: var(--success);
}

.status-label {
  font-family: var(--font-body);
  font-weight: 500;
}

/* -- Main content -- */
.conversations-main {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px;
  flex: 1;
  overflow-y: auto;
}

/* New conversation button */
.btn-new-conversation {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 24px;
  background: var(--accent);
  color: var(--bg-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  border: var(--border-width) solid #b8923a;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: all 0.15s ease;
  margin-bottom: 28px;
}

.btn-new-conversation:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: var(--accent-bright);
}

.btn-new-conversation:active {
  transform: translateY(2px);
  box-shadow: 1px 1px 0px #0d0c0a;
}

.btn-new-icon {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.btn-new-text {
  /* inherits from parent */
}

/* Conversation list */
.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Conversation card (generated by JS — anticipated structure) */
.conversation-card {
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.conversation-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.conversation-card:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0px #0d0c0a;
}

.conversation-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.conversation-title::before {
  content: '"';
  color: var(--accent);
}

.conversation-title::after {
  content: '"';
  color: var(--accent);
}

.conversation-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.conversation-timestamp {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.conversation-delete {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  opacity: 0;
}

.conversation-card:hover .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

.empty-state p {
  line-height: 2;
}

/* -- Footer -- */
.conversations-footer {
  padding: 16px 32px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

.footer-switch {
  font-size: 13px;
  color: var(--text-muted);
}

.footer-switch a {
  font-weight: 600;
}

/* ------------------------------------------------
   6. Arena Screen
   ------------------------------------------------ */
#screen-arena {
  background: var(--bg-main);
}

/* -- Arena Header -- */
.arena-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 60px;
  padding: 0 24px;
  background: var(--bg-panel);
  border-bottom: var(--border-width) solid var(--border);
  flex-shrink: 0;
}

.arena-header-left {
  justify-self: start;
}

.btn-back {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-back:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

.arena-header-center {
  text-align: center;
}

.arena-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena-header-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.arena-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.arena-partner-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
}

.typing-badge {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 500;
  animation: loadingPulse 1.4s ease-in-out infinite;
}

/* -- Arena Main: two-panel grid -- */
.arena-main {
  display: grid;
  grid-template-columns: 35% 65%;
  flex: 1;
  min-height: 0;
}

/* ============================================
   Editor Panel (Left)
   ============================================ */
.editor-panel {
  background: var(--bg-editor);
  border-right: var(--border-width) solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Panel labels — shared between editor & chat */
.panel-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel-label-icon {
  font-size: 13px;
}

.panel-label-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

/* Editor history area */
.editor-history-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

/* History items (generated by JS) */
.history-item {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  animation: fadeIn 0.25s ease;
}

.history-code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-code);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.history-code::before {
  content: '› ';
  color: var(--accent);
  font-weight: 600;
}

.history-result {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-all;
}

.history-error {
  color: var(--error);
}

/* Editor input area */
.editor-input-area {
  border-top: var(--border-width) solid var(--border);
  background: var(--bg-input);
  flex-shrink: 0;
  padding: 14px 16px 12px;
}

.editor-prompt-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-editor);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease;
}

.editor-prompt-row:focus-within {
  border-color: var(--accent);
}

.prompt-symbol {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.5;
  user-select: none;
  flex-shrink: 0;
}

.code-input {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-code);
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  resize: none;
  line-height: 1.5;
  min-height: 22px;
  max-height: 180px;
}

.code-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.editor-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-body);
}

/* Run button */
.btn-run {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 20px;
  background: var(--accent);
  color: var(--bg-deep);
  border: var(--border-width) solid #b8923a;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.btn-run:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--accent-bright);
}

.btn-run:active {
  transform: translateY(2px);
  box-shadow: 0px 0px 0px #0d0c0a;
}

/* ============================================
   Chat Panel (Right)
   ============================================ */
.chat-panel {
  background: var(--bg-chat);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Chat welcome */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
  animation: fadeIn 0.5s ease;
  flex: 1;
}

.welcome-icon {
  font-size: 44px;
  margin-bottom: 4px;
}

.chat-welcome h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.welcome-hints {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.hint code {
  font-size: 12px;
}

/* ------------------------------------------------
   Message Bubbles
   ------------------------------------------------ */
.message {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 22px;
  animation: slideUp 0.25s ease;
  position: relative;
  word-wrap: break-word;
}

.message-vikas {
  align-self: flex-start;
  background: var(--vikas-bubble);
  border: 1.5px solid var(--vikas-bubble-border);
  border-bottom-left-radius: 6px;
}

.message-ishika {
  align-self: flex-end;
  background: var(--ishika-bubble);
  border: 1.5px solid var(--ishika-bubble-border);
  border-bottom-right-radius: 6px;
}

.message-sender {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  display: block;
}

.message-vikas .message-sender {
  color: var(--vikas-color);
}

.message-ishika .message-sender {
  color: var(--ishika-color);
}

.message-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 6px;
}

.message-code::before {
  content: '› ';
  color: var(--text-muted);
  opacity: 0.6;
}

.message-output {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.45;
}

/* Error message */
.message-error {
  background: var(--error-bg);
  border-color: #d4736e30;
}

.message-error .message-output {
  color: var(--error);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
}

/* System message (no bubble) */
.message-system {
  align-self: center;
  background: none;
  border: none;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
  max-width: 100%;
  font-style: italic;
}

/* ------------------------------------------------
   Typing Indicator
   ------------------------------------------------ */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 24px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.typing-indicator.hidden {
  display: none !important;
}

.typing-indicator.visible {
  display: flex !important;
}

.typing-name {
  font-weight: 600;
  color: var(--text-secondary);
}

.typing-dots {
  display: inline-flex;
  gap: 1px;
  margin-left: 2px;
}

.typing-dots .dot {
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  animation: dotBounce 1.2s ease-in-out infinite;
}

.typing-dots .dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots .dot:nth-child(3) {
  animation-delay: 0.3s;
}

/* ------------------------------------------------
   7. Scrollbar Styling
   ------------------------------------------------ */
::-webkit-scrollbar {
  width: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-soft);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ------------------------------------------------
   8. Animations
   ------------------------------------------------ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounceIn {
  from { transform: scale(0.9) translateY(15px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

@keyframes dotBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  50%      { box-shadow: 0 0 8px 2px currentColor; }
}

/* ------------------------------------------------
   9. Utility Classes
   ------------------------------------------------ */
/* .hidden and .visible already defined above */

/* ------------------------------------------------
   10. Responsive — desktop-first, handle ≥900px
   ------------------------------------------------ */
@media (max-width: 1024px) {
  .arena-main {
    grid-template-columns: 38% 62%;
  }

  .identity-title {
    font-size: 44px;
  }

  .identity-btn {
    width: 190px;
    height: 130px;
  }
}

@media (max-width: 900px) {
  .arena-main {
    grid-template-columns: 42% 58%;
  }

  .conversations-header {
    padding: 16px 20px;
  }

  .conversations-main {
    padding: 20px 16px;
  }
}
