/* ============================================
   ORANGE NOTES — Visual Environment
   Warm, quiet, human, lightly worn
   ============================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  color: #3D3D3D;
  background: #F5F1EB;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Color Tokens ---- */
:root {
  --linen: #F5F1EB;
  --charcoal: #3D3D3D;
  --terracotta: #C67D5F;
  --forest: #2F4F3F;
  --sand: #E8DCC4;
  --terracotta-soft: rgba(198, 125, 95, 0.12);
}

/* ---- App Shell ---- */
#app {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* ---- Views ---- */
.view {
  position: fixed;
  inset: 0;
  background: var(--linen);
  display: flex;
  flex-direction: column;
  opacity: 0;
  animation: warmArrive 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.view.hidden {
  display: none;
  opacity: 0;
  animation: none;
}

@keyframes warmArrive {
  from {
    opacity: 0;
    filter: brightness(1.05);
  }
  to {
    opacity: 1;
    filter: brightness(1);
  }
}

/* ---- First Welcome ---- */
.first-welcome {
  position: fixed;
  inset: 0;
  background: var(--linen);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: welcomeFade 3s ease forwards;
  pointer-events: none;
}

.first-welcome.done {
  display: none;
}

.welcome-line {
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  color: var(--forest);
  opacity: 0;
  animation: lineAppear 1s ease 0.5s forwards;
}

@keyframes welcomeFade {
  0% { opacity: 1; }
  60% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes lineAppear {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 0.7; transform: translateY(0); }
}

/* ---- Today View ---- */
.today-view {
  padding: 0;
}

.today-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem 0.5rem;
  flex-shrink: 0;
}

.date-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--forest);
  opacity: 0.6;
}

.nav-actions {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--forest);
  opacity: 0.5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: opacity 300ms ease, background 300ms ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover {
  opacity: 0.8;
  background: var(--terracotta-soft);
}

.nav-btn:active {
  opacity: 1;
  transform: scale(0.96);
}

/* ---- Writing Area ---- */
.writing-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 1.5rem 2rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Yesterday's Residue */
.yesterday-residue {
  font-family: 'Caveat', cursive;
  font-size: 0.875rem;
  color: var(--terracotta);
  opacity: 0;
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
  line-height: 1.5;
  max-height: 0;
  overflow: hidden;
  transition: opacity 600ms ease 400ms, max-height 600ms ease 400ms, margin-bottom 600ms ease 400ms;
}

.yesterday-residue.visible {
  opacity: 0.55;
  max-height: 80px;
  margin-bottom: 0.75rem;
}

.yesterday-residue::before {
  content: "... ";
  opacity: 0.4;
}

/* Prompt */
.prompt {
  font-family: 'Caveat', cursive;
  font-size: 1rem;
  color: var(--terracotta);
  opacity: 0;
  margin-bottom: 1rem;
  padding-left: 0.25rem;
  line-height: 1.5;
  max-height: 0;
  overflow: hidden;
  transition: opacity 500ms ease 600ms, max-height 500ms ease 600ms, margin-bottom 500ms ease 600ms;
}

.prompt.visible {
  opacity: 0.7;
  max-height: 60px;
  margin-bottom: 1rem;
}

/* ---- Writing Surface ---- */
.note-input {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--charcoal);
  resize: none;
  padding: 0.25rem 0;
  caret-color: var(--terracotta);
}

.note-input::placeholder {
  color: var(--forest);
  opacity: 0.25;
}

/* Remove default textarea glow on focus */
.note-input:focus {
  outline: none;
  box-shadow: none;
}

/* ---- Save Indicator ---- */
.save-indicator {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--terracotta);
  opacity: 0;
  transition: opacity 400ms ease;
  z-index: 50;
}

.save-indicator.saving {
  opacity: 0.35;
}

.save-indicator.saved {
  opacity: 0;
  transition: opacity 1200ms ease 800ms;
}

/* ---- Archive View ---- */
.archive-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem 1rem;
  flex-shrink: 0;
}

.back-btn {
  opacity: 0.6;
}

.archive-title {
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--forest);
  opacity: 0.7;
}

.archive-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1.5rem 2rem;
}

.archive-card {
  background: var(--sand);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 300ms ease;
  -webkit-tap-highlight-color: transparent;
}

.archive-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(61, 61, 61, 0.06);
}

.archive-card:active {
  transform: scale(0.99);
}

.archive-card-date {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--forest);
  opacity: 0.5;
  margin-bottom: 0.5rem;
}

.archive-card-preview {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--charcoal);
  opacity: 0.75;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Empty archive state */
.archive-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--forest);
  opacity: 0.4;
  font-size: 0.875rem;
}

/* ---- Scrollbar (subtle) ---- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--sand);
  border-radius: 2px;
}

/* ---- Selection ---- */
::selection {
  background: var(--terracotta-soft);
  color: var(--charcoal);
}

/* ---- Mobile adjustments ---- */
@media (max-width: 480px) {
  .today-header {
    padding: 1rem 1.25rem 0.5rem;
  }
  
  .writing-area {
    padding: 0.5rem 1.25rem 1.5rem;
  }
  
  .archive-header {
    padding: 1rem 1.25rem 0.75rem;
  }
  
  .archive-list {
    padding: 0 1.25rem 1.5rem;
  }
  
  .note-input {
    font-size: 1rem; /* Prevent iOS zoom */
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
