/* =========================================================
   Senioren-Assistent — Design-Sprache
   Warm, ruhig, gut lesbar. Wie eine morgendliche Zeitung auf dem Küchentisch.
   ========================================================= */

:root {
  --paper:        #FAF4EA;
  --paper-card:   #FCF8F1;
  --ink:          #2B1F14;
  --ink-soft:     #6B5D4E;
  --ink-ghost:    #A49684;
  --rule:         #E3D8C6;
  --rule-strong:  #BFB09A;

  --terra:        #B64D2F;
  --terra-deep:   #8F3A1F;
  --terra-soft:   #F2E0D6;

  --sage:         #5A6E2C;
  --plum:         #6B3951;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Manrope', system-ui, sans-serif;

  --shadow-lift:  0 1px 2px rgba(43, 31, 20, 0.04),
                  0 8px 24px rgba(43, 31, 20, 0.06);
  --shadow-btn:   0 2px 4px rgba(143, 58, 31, 0.2),
                  0 12px 32px rgba(143, 58, 31, 0.25);

  /* Rechte Spalte — steuert Platz rechts */
  --avatar-w: min(24vw, 320px);
}

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

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(182, 77, 47, 0.035), transparent 60%),
    radial-gradient(ellipse at 90% 90%, rgba(107, 57, 81, 0.03),  transparent 55%);
  z-index: 0;
}

/* ───────── Rechte Spalte: Mic + Einkauf + Avatar ────────── */

/* Mic-Button — zentriert in der rechten Spalte, oben */
.mic {
  position: fixed;
  right: calc(var(--avatar-w) / 2 - 52px);
  top: 2vh;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: none;
  background: var(--terra);
  color: var(--paper);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  display: grid;
  place-items: center;
  z-index: 20;
  pointer-events: all;
  transition: transform 160ms cubic-bezier(.2,.7,.3,1), background 300ms ease;
  -webkit-tap-highlight-color: transparent;
}

.mic:active   { transform: scale(0.93); }
.mic:disabled { cursor: default; }

.mic__icon {
  width: 44px;
  height: 44px;
  fill: currentColor;
  z-index: 2;
  transition: opacity 300ms ease;
}

.mic__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--terra);
  opacity: 0;
  pointer-events: none;
}

/* Ruhe-Atmung */
@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: 0.0; }
  50%       { transform: scale(1.22); opacity: 0.35; }
}
.mic[data-state="idle"] .mic__ring--1 { animation: breathe 3.2s ease-in-out infinite; }

/* Aufnahme-Pulse */
@keyframes pulseOut {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0;   }
}
.mic[data-state="listening"] .mic__ring--1,
.mic[data-state="recording"] .mic__ring--1,
.mic[data-state="recording"] .mic__ring--2,
.mic[data-state="recording"] .mic__ring--3 {
  animation: pulseOut 1.6s ease-out infinite;
}
.mic[data-state="recording"] .mic__ring--2 { animation-delay: 0.4s; }
.mic[data-state="recording"] .mic__ring--3 { animation-delay: 0.8s; }

/* Farbwechsel je Zustand */
.mic[data-state="speaking"]    { background: var(--plum);      }
.mic[data-state="listening"]   { background: var(--terra-deep);}
.mic[data-state="recording"]   { background: var(--terra-deep);}
.mic[data-state="processing"]  { background: var(--ink-soft);  }
.mic[data-state="processing"] .mic__icon { opacity: 0.4; }
.mic[data-state="timeout"]     { background: var(--ink-ghost); }

/* Proaktive Ansage */
.mic[data-announcement="true"] { background: var(--plum); }
.mic[data-announcement="true"] .mic__ring--1 {
  border-color: var(--plum);
  animation: breathe 2.6s ease-in-out infinite !important;
  opacity: 0.4;
}

/* Processing-Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.mic[data-state="processing"] .mic__ring--1 {
  opacity: 0.6;
  border-top-color: var(--paper);
  border-right-color: transparent;
  border-bottom-color: transparent;
  border-left-color: transparent;
  animation: spin 900ms linear infinite;
}

/* Rechte Spalte: Einkauf + Avatar */
.right-panel {
  position: fixed;
  right: 0;
  top: calc(2vh + 104px + 12px);
  bottom: 0;
  width: var(--avatar-w);
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

/* Einkaufsliste */
.shopping-list {
  list-style: none;
  padding: 12px 14px 10px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  margin: 0 10px;
  flex-shrink: 0;
  max-height: 42vh;
  overflow: hidden;
}

.shopping-list::before {
  content: '🛒 Einkauf';
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terra);
  margin-bottom: 8px;
}

.shopping__item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  border-top: 1px solid var(--rule);
}
.shopping__item:first-of-type { border-top: none; }

.shopping__icon {
  color: var(--terra);
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.shopping__text {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--ink);
  line-height: 1.3;
}

.shopping__empty {
  font-size: 13px;
  color: var(--ink-ghost);
  font-style: italic;
}

.avatar-img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
}

/* Avatar-Sprech-Animation: leichtes Wippen wenn speaking */
@keyframes avatarTalk {
  0%, 100% { transform: translateY(0px) rotate(0deg);    }
  25%       { transform: translateY(-6px) rotate(-0.8deg); }
  75%       { transform: translateY(-3px) rotate(0.8deg);  }
}
.avatar--talking {
  animation: avatarTalk 1.2s ease-in-out infinite;
  transform-origin: bottom center;
}

/* ───────── Haupt-Layout ─────────────────────────────────── */

.page {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 20px 24px 16px 28px;
  padding-right: calc(var(--avatar-w) + 16px);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 16px;
}

/* ───────── Kopfzeile ────────────────────────────────── */

.page__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.salute { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }

.salute__hello {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 32px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.salute__date {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  color: var(--ink-soft);
}

.clock {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  font-size: 30px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ───────── Grid: Heute & Vorschau — flach, breit ───────── */

.grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 16px 22px 18px;
  box-shadow: var(--shadow-lift);
  animation: fadeUp 500ms cubic-bezier(.2,.7,.3,1) both;
}

.card--today    { animation-delay: 40ms; }
.card--upcoming { animation-delay: 120ms; }

.card__head { margin-bottom: 12px; }

.card__eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--terra);
  margin-bottom: 6px;
}

.card__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ink);
}

/* Tagesagenda — kompakter */

.agenda {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.agenda__item {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 16px;
  align-items: baseline;
  padding: 9px 0;
  border-top: 1px solid var(--rule);
}

.agenda__item:first-child { border-top: none; padding-top: 2px; }

.agenda__time {
  font-family: var(--font-display);
  font-feature-settings: 'tnum' 1;
  font-weight: 500;
  font-size: 18px;
  color: var(--ink-soft);
}

.agenda__title {
  font-size: 18px;
  line-height: 1.3;
  color: var(--ink);
}

.agenda__item[data-kind="health"]       .agenda__time { color: var(--sage); }
.agenda__item[data-kind="family"]       .agenda__time { color: var(--plum); }
.agenda__item[data-kind="appointment"]  .agenda__time { color: var(--terra); }

.agenda__item--past .agenda__time,
.agenda__item--past .agenda__title { color: var(--ink-ghost); }
.agenda__item--past { opacity: 0.55; }

/* Nächste Tage — kompakter */

.days { list-style: none; display: flex; flex-direction: column; }

.days__item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid var(--rule);
}
.days__item:first-child { border-top: none; padding-top: 2px; }

.days__day {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  color: var(--ink-soft);
}

.days__entries { display: flex; flex-direction: column; gap: 2px; }

.days__entry { display: flex; gap: 10px; align-items: baseline; }

.days__entry-time {
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-size: 14px;
  min-width: 46px;
}

.days__entry-title {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.3;
}

.days__empty {
  color: var(--ink-ghost);
  font-style: italic;
  font-size: 14px;
}

/* ───────── Aufgaben — volle Breite, Grid ───────────────── */

.memory {
  animation: fadeUp 500ms cubic-bezier(.2,.7,.3,1) both;
  animation-delay: 180ms;
}

.memory__head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.memory__rule {
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.memory__list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.memory__item {
  background: transparent;
  border-left: 3px solid var(--terra);
  padding: 8px 12px 9px 14px;
  line-height: 1.35;
}

.memory__text {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  color: var(--ink);
  letter-spacing: -0.005em;
  display: block;
  margin-bottom: 3px;
}

.memory__meta {
  font-size: 12px;
  color: var(--ink-ghost);
  letter-spacing: 0.02em;
}

/* ───────── Dock: Status-Text (kein eigener Bereich mehr) ── */

.dock {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 0 4px;
}

.dock__announce {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--plum);
  background: rgba(107, 57, 81, 0.08);
  padding: 5px 10px 4px;
  border-radius: 999px;
  animation: fadeSoft 400ms ease-out both;
}
.dock__announce[hidden] { display: none; }

.dock__heard {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink-ghost);
  font-style: italic;
  line-height: 1.4;
  animation: fadeSoft 400ms ease-out both;
}
.dock__heard[hidden] { display: none; }

.dock__status {
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.3;
  color: var(--ink-soft);
  min-height: 24px;
  letter-spacing: -0.005em;
  transition: color 300ms ease;
}

/* ───────── Animationen ─────────────────────────────────── */

@keyframes fadeUp {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0);    }
}

@keyframes fadeSoft {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* ───────── Responsive (Portrait & kleinere Screens) ────── */

@media (max-width: 860px) {
  :root { --avatar-w: 0px; }
  .avatar-panel { display: none; }
  .mic {
    position: static;
    width: 120px;
    height: 120px;
    margin: 8px auto 0;
  }
  .mic__icon { width: 46px; height: 46px; }
  .page { padding: 16px 16px 12px; gap: 14px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .salute__hello { font-size: 26px; }
  .clock { font-size: 24px; }
  .dock { align-items: center; }
  .dock__status { text-align: center; }
}
