/* ============================================================
   Personal OS — PWA v0.2
   Mobile-first natif iOS + dashboard desktop 2 colonnes + onglets Pro/Perso.
   Palette beige + orange magique. Inspiré Revolut, version chaleureuse.
   ============================================================ */

:root {
  /* Palette de base */
  --bg-canvas: #F7F1E5;
  --bg-surface: #FFFCF5;
  --bg-surface-elev: #FFFDF8;
  --bg-deep: #ECE4D2;

  /* Texte */
  --text-primary: #2A2520;
  --text-secondary: #7A6F62;
  --text-muted: #A89D8E;

  /* Accents — l'orange magique */
  --orange: #FF7A1A;
  --orange-bright: #FF9230;
  --orange-glow: #FFB347;
  --orange-soft: #FFD9B0;
  --orange-deep: #B8540F;

  /* Système */
  --success: #5C9B47;
  --border: #E8DFD0;
  --border-strong: #D6CAB3;

  /* Effets */
  --shadow-soft: 0 4px 24px rgba(42, 37, 32, 0.06);
  --shadow-card: 0 2px 12px rgba(42, 37, 32, 0.04), 0 1px 3px rgba(42, 37, 32, 0.03);
  --shadow-glow: 0 0 32px rgba(255, 122, 26, 0.22), 0 0 64px rgba(255, 179, 71, 0.12);
  --shadow-glow-strong: 0 0 48px rgba(255, 122, 26, 0.35), 0 0 96px rgba(255, 179, 71, 0.18);

  /* Animations */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --gap: 14px;
  --gap-lg: 18px;

  /* Touch (Apple HIG : min 44px) */
  --touch-target: 44px;
}

/* ============================================================
   Reset + base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* enlève le flash gris au tap iOS */
}

html, body {
  height: 100%;
}

html {
  /* Empêche le bounce blanc en haut sur iOS quand on tire vers le bas */
  background: var(--bg-canvas);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* Safe area iOS — gère encoche et bottom bar */
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  /* Plus de lag sur tap iOS */
  touch-action: manipulation;
}

ul { list-style: none; }

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  background: transparent;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

/* ============================================================
   Aurora background — les orbes orange "magiques" qui rayonnent
   ============================================================ */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.aurora-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: drift 24s ease-in-out infinite;
  will-change: transform;
}

.aurora-orb--1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, var(--orange) 0%, transparent 60%);
  top: -120px; right: -100px;
  animation-delay: 0s;
}

.aurora-orb--2 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, var(--orange-glow) 0%, transparent 65%);
  top: 40%; left: -120px;
  animation-delay: -8s;
  opacity: 0.4;
}

.aurora-orb--3 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, var(--orange-bright) 0%, transparent 70%);
  bottom: -80px; right: 30%;
  animation-delay: -16s;
  opacity: 0.35;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 40px) scale(0.95); }
}

/* Réduit les animations si l'utilisateur préfère le calme */
@media (prefers-reduced-motion: reduce) {
  .aurora-orb { animation: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   Layout principal
   ============================================================ */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 80px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ============================================================
   Header sticky avec effet flou type iOS
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -16px;
  padding-top: 12px;
  padding-bottom: 4px;
  /* Effet "frosted glass" type barre de nav iOS */
  background: rgba(247, 241, 229, 0.7);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  transition: padding 0.3s var(--ease);
}

.header__bar {
  padding: 8px 16px 12px;
}

.header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.header__greeting {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header__date {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.header__intention {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.intention-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.intention-text {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ============================================================
   Filter toggle — visible sur mobile, masqué sur desktop
   ============================================================ */
.filter {
  position: relative;
  display: flex;
  background: var(--bg-deep);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  margin: 4px 0 6px;
}

.filter__btn {
  flex: 1;
  min-height: var(--touch-target);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  z-index: 2;
  transition: color 0.3s var(--ease);
}

.filter__btn.is-active {
  color: var(--text-primary);
}

.filter__btn.is-active span {
  text-shadow: 0 0 24px rgba(255, 122, 26, 0.4);
}

.filter__indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: calc(33.333% - 4px);
  background: var(--bg-surface);
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(42, 37, 32, 0.08), 0 0 16px rgba(255, 122, 26, 0.2);
  transition: transform 0.4s var(--ease-out);
  z-index: 1;
  left: 4px;
}

/* États du curseur selon le filtre actif */
.filter[data-active="all"] .filter__indicator { transform: translateX(0); }
.filter[data-active="pro"] .filter__indicator { transform: translateX(100%); }
.filter[data-active="perso"] .filter__indicator { transform: translateX(200%); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-card);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.card__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card__badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-deep);
  color: var(--text-secondary);
}

/* ============================================================
   Top row : météo + agenda
   ============================================================ */
.top-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

/* ============================================================
   Progress card — l'élément qui rayonne le plus
   ============================================================ */
.progress-card {
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface-elev) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.progress-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 30%, rgba(255, 179, 71, 0.18) 0%, transparent 50%);
  pointer-events: none;
}

.progress-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  position: relative;
}

.progress-card__label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.progress-card__count {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.progress-card__total {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 2px;
}

.progress-bar {
  height: 8px;
  background: var(--bg-deep);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange) 0%, var(--orange-glow) 100%);
  border-radius: 999px;
  transition: width 0.6s var(--ease);
  box-shadow: 0 0 12px rgba(255, 122, 26, 0.6);
  position: relative;
}

.progress-bar__fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
  animation: shimmer 2.4s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

/* ============================================================
   Météo
   ============================================================ */
.weather__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.weather__main {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.weather__temp {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--orange) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.weather__condition {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
}

.weather__advice {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 10px 12px;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

/* ============================================================
   Agenda
   ============================================================ */
.agenda__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agenda__item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-surface-elev);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--orange);
}

.agenda__time {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.agenda__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.agenda__context {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.agenda__empty, .todo__empty, .news__empty {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  padding: 6px 0;
}

/* ============================================================
   Dashboard 2 colonnes (desktop) / 1 colonne (mobile)
   ============================================================ */
.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

.dashboard__col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.col-title {
  display: none; /* masqué sur mobile, visible sur desktop */
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 4px 0;
}

.col-title__chip {
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--orange-deep);
  letter-spacing: 0.1em;
}

.col-title--pro .col-title__chip {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-bright) 100%);
  color: white;
  box-shadow: 0 0 12px rgba(255, 122, 26, 0.4);
}

/* ============================================================
   Todo / Cases à cocher — touch targets ≥ 44px
   ============================================================ */
.todo__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
  min-height: var(--touch-target);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  transition: opacity 0.2s var(--ease);
  border-radius: var(--radius-xs);
}

.check:active {
  background: rgba(255, 122, 26, 0.06);
}

.check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check__box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg-surface-elev);
  flex-shrink: 0;
  position: relative;
  transition: all 0.25s var(--ease);
}

.check__box::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 6px;
  width: 5px;
  height: 11px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.25s var(--ease);
}

.check__label {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.4;
  transition: color 0.3s var(--ease), text-decoration-color 0.3s var(--ease);
  text-decoration: line-through transparent;
}

.check input[type="checkbox"]:checked + .check__box {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-glow) 100%);
  border-color: var(--orange);
  box-shadow: 0 0 16px rgba(255, 122, 26, 0.55), 0 0 32px rgba(255, 179, 71, 0.3);
}

.check input[type="checkbox"]:checked + .check__box::after {
  transform: rotate(45deg) scale(1);
}

.check input[type="checkbox"]:checked ~ .check__label {
  color: var(--text-muted);
  text-decoration-color: var(--text-muted);
}

.check:hover .check__box {
  border-color: var(--orange);
}

/* ============================================================
   Health — Forme & santé (alimenté par Raccourci iOS)
   ============================================================ */
.health__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.health__metric {
  background: var(--bg-surface-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.health__metric::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 60px; height: 60px;
  background: radial-gradient(circle, rgba(255, 179, 71, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.health__value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.health__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

/* ============================================================
   News
   ============================================================ */
.news__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.news__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-surface-elev);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.news__topic {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange);
}

.news__headline {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.news__source {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   Gift — la récompense de fin de journée
   ============================================================ */
.gift {
  background: linear-gradient(135deg, var(--orange-soft) 0%, #FFE8C9 100%);
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  box-shadow: var(--shadow-glow-strong);
  animation: gift-appear 0.8s var(--ease);
}

@keyframes gift-appear {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.gift__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--orange);
  display: block;
  margin-bottom: 12px;
}

.gift__content {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-size: 20px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-primary);
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 4px env(safe-area-inset-bottom);
  font-size: 11px;
  color: var(--text-muted);
}

.footer__sync::before {
  content: '●';
  color: var(--success);
  margin-right: 6px;
  animation: pulse 2.4s ease-in-out infinite;
}

.footer__sync.is-syncing::before { color: var(--orange); }

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

/* ============================================================
   Animation d'entrée des cards (subtile, à l'ouverture)
   ============================================================ */
.card, .progress-card {
  animation: card-fade-in 0.5s var(--ease-out) backwards;
}

.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.11s; }

@keyframes card-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Filtre actif : masque le domaine non sélectionné
   ============================================================ */
.app[data-filter="pro"] [data-domain="perso"],
.app[data-filter="pro"] .col-title--perso,
.app[data-filter="perso"] [data-domain="pro"],
.app[data-filter="perso"] .col-title--pro {
  display: none;
}

/* ============================================================
   Breakpoint Tablette : 600px+
   ============================================================ */
@media (min-width: 600px) {
  .top-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================
   Breakpoint Desktop : 1024px+ — vrai mode dashboard
   ============================================================ */
@media (min-width: 1024px) {
  .app {
    max-width: 1280px;
    padding: 0 32px 80px;
  }

  /* Header non sticky en desktop, plus aéré */
  .header {
    position: static;
    margin: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding-top: 32px;
    padding-bottom: 12px;
  }

  .header__bar {
    padding: 0;
  }

  .intention-text {
    font-size: 40px;
  }

  /* Le toggle Pro/Perso est masqué : la grille les montre côte à côte */
  .filter {
    display: none;
  }

  /* Dashboard en 2 colonnes */
  .dashboard {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  .col-title {
    display: flex;
  }

  /* Plus de largeur pour la météo et l'agenda en haut */
  .top-row {
    grid-template-columns: 1fr 2fr;
  }

  .weather__temp {
    font-size: 56px;
  }

  .health__grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* En desktop on force tout à afficher même si data-filter est set */
  .app[data-filter="pro"] [data-domain="perso"],
  .app[data-filter="pro"] .col-title--perso,
  .app[data-filter="perso"] [data-domain="pro"],
  .app[data-filter="perso"] .col-title--pro {
    display: revert;
  }
}

/* ============================================================
   Très grand écran : 1440px+
   ============================================================ */
@media (min-width: 1440px) {
  .app {
    max-width: 1440px;
  }

  .gap { gap: 20px; }
}
