/* Coquille du faux iPhone : cadre, barre d'état, écran d'accueil, dock, notifications. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Inter, system-ui, sans-serif;
  --blue: #0a84ff;
  --green: #34c759;
  --red: #ff3b30;
  --label2: #8a8a8e;
  --sep: rgba(60, 60, 67, 0.29);
  --ios: cubic-bezier(0.32, 0.72, 0, 1);
  --top: 54px; /* hauteur de la barre d'état dans le cadre */
  --bottom: 34px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  display: grid; place-items: center; font-family: var(--font); color: #000;
  background: radial-gradient(120% 90% at 50% 10%, #3a2a3f 0%, #120d16 60%, #07060a 100%);
  -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }

/* ---------- Le téléphone (cadre sur ordinateur, plein écran sur téléphone) ---------- */
.device {
  position: relative; width: 393px; height: 852px; padding: 11px; border-radius: 62px;
  background: linear-gradient(145deg, #2c2c30, #0d0d10 40%, #1c1c20);
  box-shadow: 0 0 0 2px #3b3b40, 0 40px 90px rgba(0, 0, 0, 0.6), inset 0 0 6px rgba(255, 255, 255, 0.15);
  transform: scale(var(--fit, 1)); transform-origin: center;
}
.screen {
  position: relative; width: 100%; height: 100%; border-radius: 51px; overflow: hidden;
  background: #000; isolation: isolate; contain: layout paint;
}
html.native .device { width: 100vw; height: 100dvh; padding: 0; border-radius: 0; box-shadow: none; transform: none; background: #000; }
html.native .screen { border-radius: 0; }
/* Sur un vrai téléphone, l'heure, la batterie et l'encoche sont celles du téléphone : on n'affiche pas les nôtres. */
html.native { --top: max(env(safe-area-inset-top), 10px); --bottom: max(env(safe-area-inset-bottom), 14px); }
html.native .statusbar, html.native .island { display: none; }

/* ---------- Fond d'écran ---------- */
.wallpaper { position: absolute; inset: 0; z-index: 0; background: #6b5a45 url("../assets/wallpaper.webp") center / cover no-repeat; }

/* ---------- Barre d'état ---------- */
.statusbar {
  position: absolute; top: 0; left: 0; right: 0; height: 54px; z-index: 60; pointer-events: none;
  display: flex; align-items: center; justify-content: space-between; padding: 4px 34px 0 44px;
  color: #fff; transition: color 200ms ease;
}
.screen[data-theme="light"] .statusbar { color: #000; }
.sb-time { font-weight: 600; font-size: 17px; letter-spacing: -0.2px; }
.sb-icons { display: flex; align-items: center; gap: 6px; fill: currentColor; }
.sb-5g { font-weight: 600; font-size: 15px; }
.battery { position: relative; width: 27px; height: 13px; border-radius: 4px; background: rgba(255, 255, 255, 0.35); overflow: hidden; display: grid; place-items: center; }
.screen[data-theme="light"] .battery { background: rgba(0, 0, 0, 0.3); }
.battery-level { position: absolute; inset: 0 31% 0 0; background: currentColor; }
.battery-num { position: relative; font-size: 10px; font-weight: 700; color: #000; }
.screen[data-theme="light"] .battery-num { color: #fff; }
.island { position: absolute; top: 11px; left: 50%; width: 125px; height: 37px; margin-left: -62.5px; border-radius: 20px; background: #000; }

/* ---------- Écran d'accueil ---------- */
.home {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(var(--top) + 14px) 0 max(8px, calc(var(--bottom) - 14px));
  transition: transform 420ms var(--ios), opacity 420ms var(--ios), filter 420ms var(--ios);
}
/* pages de l'écran d'accueil : on glisse vers la 2e page (fond d'écran seul), le dock reste */
.home-pages { flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.home-pages::-webkit-scrollbar { display: none; }
.home-page { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always; }
.home-bottom { position: relative; }
.page-dots { position: absolute; top: 9px; left: 50%; transform: translateX(-50%); display: flex; gap: 9px; opacity: 0; transition: opacity 200ms ease; }
.page-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); }
.page-dots i.on { background: #fff; }
.home.paging .page-dots, .home[data-page="1"] .page-dots { opacity: 1; }
.home.paging .search-pill, .home[data-page="1"] .search-pill { opacity: 0; }
.search-pill { transition: opacity 200ms ease; }
.home.behind { transform: scale(0.9); opacity: 0.35; filter: blur(3px); }
.home-top {
  display: grid; grid-template-columns: repeat(4, 64px); grid-auto-rows: 86px; justify-content: space-between;
  row-gap: clamp(2px, calc((var(--screen-h, 830px) - 660px) / 5), 20px); padding: 0 24px; align-content: start;
}
.home-grid { display: contents; }
.app-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 64px; }
.app-btn .label, .widget-wrap .label {
  width: 84px; text-align: center; font-size: 12px; line-height: 16px; font-weight: 500; color: #fff; letter-spacing: -0.1px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon {
  position: relative; flex: none; width: 64px; height: 64px; border-radius: 14.5px; overflow: hidden; display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); transition: transform 160ms ease-out, filter 160ms ease-out;
}
.icon svg, .icon img { display: block; width: 100%; height: 100%; }
.icon img { width: 100%; height: 100%; object-fit: cover; }
.app-btn:active .icon { transform: scale(0.94); filter: brightness(0.82); }
.badge {
  position: absolute; top: -7px; right: -8px; z-index: 2; min-width: 23px; height: 23px; padding: 0 6px; border-radius: 12px;
  background: var(--red); color: #fff; font-size: 14px; font-weight: 600; display: grid; place-items: center;
}

/* widgets (2 x 2) : du haut de la 1re icône au bas de la 2e, le nom en dessous */
.widget-wrap { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.widget-wrap-weather { grid-column: 1 / 3; grid-row: 1 / 3; }
.widget-wrap .label { width: auto; }
.widget {
  width: 100%; flex: 1; max-height: 170px; border-radius: 22px; padding: 14px 15px; text-align: left;
  display: flex; flex-direction: column; color: #fff; position: relative; overflow: hidden;
  box-shadow: 0 6px 16px rgba(60, 10, 30, 0.25); transition: transform 160ms ease-out;
}
.widget:active { transform: scale(0.97); }
.widget-weather { background: linear-gradient(180deg, #ff7a2e 0%, #f24c2f 100%); }
.ww-city { font-size: 15px; font-weight: 600; }
.ww-temp { font-size: 42px; font-weight: 300; letter-spacing: -1.5px; line-height: 1.05; }
.ww-sun { width: 18px; height: 18px; margin-top: auto; border-radius: 50%; background: #ffd60a; box-shadow: 0 0 0 3px rgba(255, 214, 10, 0.35); }
.ww-cond { font-size: 13px; font-weight: 600; margin-top: 4px; }
.ww-range { font-size: 12px; font-weight: 500; opacity: 0.92; white-space: nowrap; letter-spacing: -0.2px; }

.home-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.search-pill {
  display: flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; color: #fff;
  background: rgba(255, 255, 255, 0.28); backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.dock {
  width: calc(100% - 24px); height: 92px; border-radius: 34px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: rgba(255, 255, 255, 0.3); backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.dock .label { display: none; }

/* ---------- Barre de retour à l'accueil ---------- */
/* la barre du bas n'apparaît que dans une appli, comme sur iPhone */
.app[hidden] ~ .homebar { display: none; }
.homebar { position: absolute; left: 50%; bottom: 0; width: 180px; height: 26px; margin-left: -90px; z-index: 70; display: grid; place-items: center; }
.homebar span { width: 134px; height: 5px; border-radius: 3px; background: #fff; transition: background 200ms ease; }
.screen[data-theme="light"] .homebar span { background: #000; }

/* ---------- Appli ouverte ---------- */
.app { position: absolute; inset: 0; z-index: 40; overflow: hidden; background: #fff; will-change: transform; }
.app[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .home { transition-duration: 1ms; }
}
