/*
 * Via Vitae — Prototype CSS
 * Полная палитра и типографика по design_system.md
 * Mobile-first. iPhone 15 Pro 393×852 baseline.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=PT+Serif:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  /* === Палитра Via Vitae === */
  --milk: #FAF7F2;
  --beige: #EDE5D6;
  --beige-deep: #E0D6C2;
  --terracotta: #C66B4A;
  --terracotta-deep: #A8553A;
  --olive: #7A8450;
  --olive-light: #9DA86B;
  --ochre: #D4A554;
  --sage: #A8B89B;
  --sage-light: #C2D0B7;
  --charcoal: #2C2925;
  --mist: #7C7770;
  --paper: #FFFFFF;

  /* === Размеры === */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-soft: 0 1px 4px rgba(44, 41, 37, 0.04);
  --shadow-card: 0 2px 12px rgba(44, 41, 37, 0.06);
  --shadow-modal: 0 8px 32px rgba(44, 41, 37, 0.12);

  /* === Типографика === */
  --font-serif: 'PT Serif', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --text-display: 2.25rem;   /* 36px */
  --text-headline: 1.5rem;   /* 24px */
  --text-title: 1.25rem;     /* 20px */
  --text-body-lg: 1.125rem;  /* 18px */
  --text-body: 1rem;         /* 16px */
  --text-caption: 0.875rem;  /* 14px */
  --text-small: 0.75rem;     /* 12px */

  --leading-tight: 1.25;
  --leading-snug: 1.4;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  background: var(--milk);
  color: var(--charcoal);
  font-family: var(--font-sans);
  font-size: var(--text-body-lg);
  line-height: var(--leading-normal);
  min-height: 100vh;
  overscroll-behavior: contain;
}

body {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  padding-bottom: 80px; /* для bottom nav */
}

/* === Утилиты === */

.serif { font-family: var(--font-serif); }
.sans { font-family: var(--font-sans); }

.text-mist { color: var(--mist); }
.text-terracotta { color: var(--terracotta); }
.text-olive { color: var(--olive); }

.text-display { font-size: var(--text-display); line-height: var(--leading-tight); font-weight: 400; letter-spacing: -0.02em; }
.text-headline { font-size: var(--text-headline); line-height: var(--leading-snug); font-weight: 600; }
.text-title { font-size: var(--text-title); line-height: var(--leading-snug); font-weight: 500; }
.text-body-lg { font-size: var(--text-body-lg); line-height: var(--leading-normal); }
.text-body { font-size: var(--text-body); line-height: var(--leading-normal); }
.text-caption { font-size: var(--text-caption); line-height: var(--leading-snug); color: var(--mist); }
.text-small { font-size: var(--text-small); line-height: var(--leading-snug); color: var(--mist); }

/* === Layout === */

.screen {
  min-height: 100vh;
  padding: var(--space-lg);
  padding-bottom: 100px;
  animation: fadeIn 0.3s ease-out;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  padding-top: var(--space-md);
}

.screen-title {
  font-family: var(--font-serif);
  font-size: var(--text-headline);
  font-weight: 400;
  color: var(--charcoal);
}

.screen-section {
  margin-bottom: var(--space-2xl);
}

/* === Карточки === */

.card {
  background: var(--paper);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-md);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:active {
  transform: scale(0.98);
}

.card-soft {
  background: var(--beige);
}

.card-deep {
  background: var(--beige-deep);
}

.card-large {
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

.card-tappable {
  cursor: pointer;
}

/* === Кнопки === */

button, .btn {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 500;
  border: none;
  cursor: pointer;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.18s ease;
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

button:active, .btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--terracotta);
  color: var(--paper);
}

.btn-primary:hover {
  background: var(--terracotta-deep);
}

.btn-secondary {
  background: var(--beige);
  color: var(--charcoal);
}

.btn-ghost {
  background: transparent;
  color: var(--mist);
}

.btn-block {
  width: 100%;
}

/* === Bottom nav === */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--paper);
  border-top: 1px solid var(--beige);
  padding: 8px var(--space-md);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  z-index: 10;
}

.nav-item {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  cursor: pointer;
  text-decoration: none;
  color: var(--mist);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: var(--text-small);
  font-weight: 500;
  transition: color 0.18s ease;
}

.nav-item.active {
  color: var(--terracotta);
}

.nav-icon {
  width: 24px;
  height: 24px;
  stroke-width: 1.5;
  stroke: currentColor;
  fill: none;
}

/* === Garden illustration === */

.garden-scene {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(180deg, #FFE8D2 0%, #F5DCB8 60%, #E5C895 100%);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.garden-scene::before {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 35%;
  background: linear-gradient(180deg, #B8A878 0%, #7A8450 100%);
}

.garden-sun {
  position: absolute;
  top: 12%;
  right: 18%;
  width: 56px;
  height: 56px;
  background: #F5C46A;
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(245, 196, 106, 0.4);
}

.garden-tree {
  position: absolute;
  bottom: 30%;
  width: 38px;
  height: 70px;
}

.garden-tree-trunk {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 28px;
  background: #6B4F35;
  border-radius: 2px;
}

.garden-tree-foliage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background: var(--olive);
  border-radius: 50%;
  box-shadow: inset -4px -4px 0 rgba(0,0,0,0.08);
}

.garden-tree-1 { left: 18%; bottom: 26%; }
.garden-tree-2 { left: 60%; bottom: 28%; transform: scale(0.8); }
.garden-tree-3 { left: 78%; bottom: 25%; transform: scale(1.1); }

.garden-flower {
  position: absolute;
  bottom: 12%;
  width: 8px;
  height: 18px;
}

.garden-flower::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 7px;
  background: var(--terracotta);
  border-radius: 50%;
}

.garden-flower::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5px;
  height: 12px;
  background: var(--olive);
}

.garden-flower-2::before { background: var(--ochre); }
.garden-flower-3::before { background: var(--sage); }

.garden-greeting {
  position: absolute;
  top: var(--space-lg);
  left: var(--space-lg);
  font-family: var(--font-serif);
  font-size: var(--text-title);
  color: var(--charcoal);
  font-style: italic;
}

/* === Spark card === */

.spark-card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-card);
  position: relative;
}

.spark-label {
  font-size: var(--text-small);
  color: var(--mist);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.spark-label::before {
  content: "";
  width: 16px;
  height: 1px;
  background: var(--terracotta);
}

.spark-text {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--charcoal);
  margin-bottom: var(--space-lg);
}

.spark-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-body);
  color: var(--terracotta);
  font-weight: 500;
}

.spark-action::after {
  content: "→";
  font-size: 1.2em;
}

/* === Tiny habit ===*/

.habit-card {
  background: linear-gradient(135deg, var(--beige) 0%, var(--sage-light) 100%);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.habit-label {
  font-size: var(--text-small);
  color: var(--mist);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.habit-text {
  font-size: var(--text-body-lg);
  line-height: var(--leading-snug);
  color: var(--charcoal);
}

/* === Ритуал диалог === */

.dialog-message {
  background: var(--beige);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  max-width: 85%;
}

.dialog-message.from-via {
  background: var(--beige);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.dialog-message.from-user {
  background: var(--sage-light);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  margin-left: auto;
}

.dialog-time {
  font-size: var(--text-small);
  color: var(--mist);
  margin-top: 4px;
}

.dialog-input {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 8px;
  box-shadow: var(--shadow-soft);
}

.dialog-input input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  padding: 12px var(--space-md);
  background: transparent;
}

.dialog-input button {
  min-height: 44px;
  padding: 8px 20px;
}

/* === Long read === */

.longread-body {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--charcoal);
  max-width: 36rem;
  margin: 0 auto;
}

.longread-body h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-xl);
  line-height: var(--leading-tight);
}

.longread-body p {
  margin-bottom: var(--space-md);
}

.longread-body p:first-of-type::first-letter {
  font-size: 3.5rem;
  float: left;
  line-height: 0.9;
  margin-right: 8px;
  margin-top: 4px;
  color: var(--terracotta);
  font-weight: 700;
}

.longread-source {
  margin-top: var(--space-2xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--beige);
  font-size: var(--text-caption);
  color: var(--mist);
  font-style: italic;
}

/* === Recipe card === */

.recipe-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #D4A87B 0%, #B07F4A 100%);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.recipe-photo-emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 96px;
}

.recipe-name {
  font-family: var(--font-serif);
  font-size: var(--text-headline);
  margin-bottom: var(--space-sm);
}

.recipe-evolution {
  background: var(--paper);
  border-left: 3px solid var(--olive);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  border-radius: var(--radius-sm);
}

.recipe-evolution-label {
  font-size: var(--text-caption);
  color: var(--olive);
  font-weight: 600;
  margin-bottom: 4px;
}

.recipe-evolution-text {
  font-size: var(--text-body);
  line-height: var(--leading-normal);
}

/* === Letter to Future Self === */

.letter-paper {
  background: linear-gradient(180deg, #FAF6E8 0%, #F0E8D2 100%);
  padding: var(--space-2xl) var(--space-xl);
  border-radius: var(--radius-md);
  font-family: var(--font-serif);
  font-style: italic;
  line-height: 1.7;
  color: var(--charcoal);
  box-shadow: var(--shadow-card);
  position: relative;
  margin-bottom: var(--space-lg);
}

.letter-paper::before {
  content: "«";
  position: absolute;
  top: 12px;
  left: 16px;
  font-size: 48px;
  color: var(--terracotta);
  font-style: normal;
  line-height: 1;
}

.letter-stamp {
  text-align: center;
  margin-top: var(--space-xl);
  font-style: normal;
  font-size: var(--text-caption);
  color: var(--mist);
  letter-spacing: 0.05em;
}

/* === Animations === */

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

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

.pulse {
  animation: breathe 4s ease-in-out infinite;
}

/* === Onboarding === */

.onboarding-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

.onboarding-illustration {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 96px;
}

.onboarding-content {
  margin-bottom: var(--space-2xl);
}

.onboarding-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  line-height: var(--leading-tight);
  margin-bottom: var(--space-md);
  color: var(--charcoal);
}

.onboarding-text {
  font-size: var(--text-body-lg);
  color: var(--mist);
  line-height: var(--leading-normal);
}

.onboarding-input {
  width: 100%;
  border: none;
  outline: none;
  background: var(--beige);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-body-lg);
  color: var(--charcoal);
  margin-bottom: var(--space-md);
  min-height: 56px;
}

.onboarding-input:focus {
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--olive-light);
}

textarea.onboarding-input {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-serif);
  font-style: italic;
  line-height: var(--leading-normal);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.chip {
  padding: 12px 20px;
  border: 1.5px solid var(--beige-deep);
  border-radius: 100px;
  background: var(--paper);
  font-size: var(--text-body);
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.chip:hover, .chip.selected {
  background: var(--sage-light);
  border-color: var(--olive);
  color: var(--charcoal);
}

/* === Modal === */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 41, 37, 0.4);
  display: flex;
  align-items: flex-end;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

.modal-sheet {
  background: var(--milk);
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-xl);
  padding-bottom: max(var(--space-xl), env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--beige-deep);
  border-radius: 2px;
  margin: 0 auto var(--space-lg);
}

/* === Index nav (для прототипа) === */

.proto-index {
  padding: var(--space-2xl) var(--space-lg);
}

.proto-index h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin-bottom: var(--space-sm);
}

.proto-index .subtitle {
  color: var(--mist);
  margin-bottom: var(--space-2xl);
  font-size: var(--text-body);
}

.proto-link {
  display: block;
  background: var(--paper);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  text-decoration: none;
  color: var(--charcoal);
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease;
}

.proto-link:active {
  transform: scale(0.98);
}

.proto-link-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: var(--text-body-lg);
}

.proto-link-desc {
  color: var(--mist);
  font-size: var(--text-caption);
}

/* === Decoration === */

.divider {
  height: 1px;
  background: var(--beige-deep);
  margin: var(--space-xl) 0;
}

.divider-decorative {
  display: flex;
  align-items: center;
  text-align: center;
  margin: var(--space-2xl) 0;
}

.divider-decorative::before,
.divider-decorative::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--beige-deep);
}

.divider-decorative::before { margin-right: var(--space-md); }
.divider-decorative::after { margin-left: var(--space-md); }

.divider-decorative-text {
  font-family: var(--font-serif);
  color: var(--olive);
  font-size: var(--text-caption);
  font-style: italic;
}

/* === Tag === */
.tag {
  display: inline-block;
  background: var(--beige);
  color: var(--mist);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: var(--text-small);
  font-weight: 500;
  margin-right: 4px;
}

/* === Back button === */

.back-button {
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--charcoal);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-body);
  font-family: var(--font-sans);
  margin-bottom: var(--space-md);
  min-height: 44px;
}

.back-button::before {
  content: "←";
  font-size: 1.4em;
}

/* === Mobile container hint === */

@media (min-width: 700px) {
  body {
    box-shadow: 0 0 60px rgba(44, 41, 37, 0.08);
    min-height: 100vh;
  }

  body::before {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background:
      linear-gradient(135deg, #E5DCC8 0%, #D5C5A5 100%);
    z-index: -1;
  }
}
