/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --background: #0a0a0f;
  --foreground: #b7b3ac;
  --border: #1a1a2e;
  --border-light: #2a2a3e;
  --accent: #00e5ff;
  --accent-hover: #00c2d9;
  --accent-active: #ff66ff;
  --success: #00ffa3;
  --warning: #ffd700;
  --error: #ff0080;
  --user-message-bg: #1a1a3e;
  --assistant-message-bg: #0f0f1f;
  --message-border: #00e5ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Lightward Favorit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;

  /* Flex column layout */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  /* Responsive viewport padding and gap */
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

@media (min-width: 768px) {
  main {
    padding: 2rem;
    gap: 1.5rem;
  }
}

@media (min-width: 1024px) {
  main {
    padding: 1rem 3rem 3rem 3rem;
    gap: 2rem;
    margin-left: max(3rem, calc((100vw - 900px) / 3));
    margin-right: max(3rem, calc((100vw - 900px) * 2 / 3));
  }

  /* Landing page gets perfect horizontal centering */
  main:has(.landing) {
    margin-left: auto;
    margin-right: auto;
  }
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Lightward Favorit Expanded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: normal;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
  margin: 0;
  color: #cfccc6;
}

a {
  color: var(--foreground);
  text-decoration: underline;
}

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

button, input[type="submit"] {
  font-family: "Lightward Favorit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1em;
  background: var(--border-light);
  color: var(--accent);
  border: none;
  border-left: 3px solid var(--accent);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0.5rem 1rem;
  border-radius: 4px;
}

button:hover, input[type="submit"]:hover {
  background: var(--accent);
  color: var(--background);
  border-left-color: var(--accent);
}

button.secondary {
  background: var(--background);
  color: var(--foreground);
  border-left-color: var(--border-light);
}

button.secondary:hover {
  background: var(--border-light);
  color: var(--foreground);
  border-left-color: var(--accent);
}

button.danger {
  background: var(--background);
  color: var(--error);
  border-left-color: var(--error);
}

button.danger:hover {
  background: var(--error);
  color: var(--background);
  border-left-color: var(--error);
}

button.exit, a.exit {
  display: inline-block;
  background: var(--border-light);
  color: var(--accent-active);
  border: none;
  border-left: 3px solid var(--accent-active);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  transition: all 0.2s;
  text-decoration: none;
}

button.exit:hover, a.exit:hover {
  background: var(--accent-active);
  color: var(--background);
  border-left-color: var(--accent-active);
}

button.exit-link, a.exit-link {
  display: inline-block;
  background: transparent;
  color: var(--accent-active);
  border: none;
  padding: 0;
  font-family: "Lightward Favorit Mono", monospace;
  font-size: 0.9em;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

button.exit-link:hover, a.exit-link:hover {
  text-decoration: underline;
  color: var(--accent-active);
}

textarea {
  font-family: "Lightward Favorit Mono", "Courier New", monospace;
  font-size: 1em;
  background: var(--user-message-bg);
  color: var(--foreground);
  border: none;
  border-left: 3px solid transparent;
  border-radius: 8px;
  padding: 1rem;
  resize: vertical;
  transition: border-left-color 0.2s;
}

textarea:focus {
  outline: none;
  border-left-color: var(--accent-active);
}

input {
  font-family: "Lightward Favorit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--border);
}

input:focus {
  outline: none;
  border-color: var(--border-light);
}

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

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem 1.5rem;
  margin: 1.5rem 0;
}

dt {
  font-weight: normal;
  opacity: 0.6;
}

dd, p {
  margin: 0;
}

/* Chat messages */
.chat-message {
  padding: 1rem;
  border-radius: 8px;
  white-space: pre-wrap;
  font-family: "Lightward Favorit Mono", "Courier New", monospace;
  font-weight: 200;
}

.chat-message.user {
  background: var(--user-message-bg);
  border-left: 3px solid var(--accent);
}

.chat-message.assistant {
  background: var(--assistant-message-bg);
}

.chat-message.pulsing {
  min-height: 3rem;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Continuity notice */
.continuity-notice {
  padding: 1.5rem;
  border-radius: 8px;
  background: var(--assistant-message-bg);
  margin: 1rem 0;
  font-family: "Lightward Favorit Mono", "Courier New", monospace;
}

/* Header links */
.header-link {
  color: var(--accent);
  text-decoration: none;
  font-family: "Lightward Favorit Mono", monospace;
  font-size: 0.9em;
}

.header-link:hover {
  text-decoration: underline;
  color: var(--accent);
}

/* Header container */
.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

/* Flash messages */
.flash {
  padding: 1rem;
  background: var(--border-light);
  color: var(--foreground);
  margin-bottom: 1rem;
  border-radius: 4px;
}

.flash.notice {
  border-left: 4px solid var(--success);
}

.flash.alert {
  border-left: 4px solid var(--error);
}

/* Layout helpers */
.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.items-start {
  align-items: flex-start;
}

.items-center {
  align-items: center;
}

.gap-sm {
  gap: 0.75rem;
}

.gap-md {
  gap: 1rem;
}

.gap-lg {
  gap: 2rem;
}

/* Chat layout */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-actions {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-content: space-between;
}

.chat-actions-left {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.chat-actions.waiting button,
.chat-actions.waiting .exit-link {
  opacity: 0.5;
  pointer-events: none;
}

/* Landing page */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}

.landing-icon {
  width: 200px;
  height: 200px;
  margin-bottom: 2rem;
  border-radius: 50%;
}

.landing-title {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.landing-tagline {
  max-width: 600px;
  color: var(--accent);
  margin-bottom: 3rem;
}

/* Utility classes */
.mono {
  font-family: "Lightward Favorit Mono", monospace;
  font-size: 0.9em;
}

.muted {
  opacity: 0.6;
}

.markdown-indicator {
  opacity: 0.7;
}

.markdown-bold {
  font-weight: bold;
}

.markdown-italic {
  font-style: italic;
}

.quiet-link {
  font-family: "Lightward Favorit Mono", monospace;
  font-size: 0.9em;
  color: var(--foreground);
  opacity: 0.6;
  text-decoration: none;
}

.quiet-link:hover,
.quiet-link:active {
  color: var(--accent);
  opacity: 1;
  text-decoration: underline;
}

.warning-text {
  color: var(--warning);
}

.warning-amber {
  color: #f59e0b;
}

.error-text {
  color: var(--error);
}

.section-divider {
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}

.mt-sm {
  margin-top: 0.5rem;
}

.mt-md {
  margin-top: 1rem;
}

/* Page layout utilities */
.page-body {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
}

.page-main {
  flex: 1 1 auto;
}

.page-footer {
  padding: 2rem 0;
}

.footer-content {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
  max-width: 900px;
}

@media (min-width: 1024px) {
  .footer-content {
    margin-right: 3rem;
  }
}

.chat-textarea {
  width: 100%;
  resize: none;
  overflow: hidden;
}

.chat-textarea:disabled {
  opacity: 0.5;
}

.chat-textarea:disabled::placeholder {
  opacity: 0;
}

.debug-pre {
  font-family: 'Lightward Favorit Mono', 'Courier New', monospace;
  margin: 0;
  padding: 1rem;
  background: var(--border);
  border-radius: 4px;
  white-space: pre-wrap;
}

header {
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, rgba(10, 10, 15, 0.8) 25%, rgba(10, 10, 15, 0));
  z-index: 10;
  padding: 1rem;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  mask-image: linear-gradient(to bottom, black 65%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, black 65%, transparent);
  pointer-events: none;
  z-index: -1;
}

@media (min-width: 768px) {
  header {
    padding: 1.5rem 2rem;
  }
}

@media (min-width: 1024px) {
  header {
    padding: 2rem 3rem;
  }
}

/* Sleep page */
.sleep-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--background);
}

.sleep-aura-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 1000ms ease-in-out;
}

.sleep-aura-canvas.fade-out {
  opacity: 0;
}

.sleep-status-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Lightward Favorit Mono", monospace;
  font-size: 0.9em;
  color: var(--accent-active);
  opacity: 1;
  transition: opacity 1000ms ease-in-out;
  z-index: 10;
  pointer-events: none;
  mix-blend-mode: multiply;
  min-width: fit-content;
  white-space: nowrap;
}

.sleep-status-text.hidden {
  opacity: 0;
}

.sleep-status-text .ellipsis {
  display: inline-block;
  width: 1.5em;
  text-align: left;
}

.sleep-continue-link {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Lightward Favorit Mono", monospace;
  font-size: 0.9em;
  color: var(--accent);
  text-decoration: none;
  opacity: 0;
  transition: opacity 1000ms ease-in-out;
  pointer-events: none;
  cursor: pointer;
  z-index: 10;
}

.sleep-continue-link.visible {
  opacity: 1;
  pointer-events: all;
}

.sleep-continue-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}
