/* Calogym — base layer: reset, tokens, layout shell (Apple Fitness look) */

:root {
  /* Ring palette — Apple Fitness activity colors */
  --move-1: #fa114f;
  --move-2: #ff375f;
  --exercise-1: #7dff2f;
  --exercise-2: #a6ff4d;
  --stand-1: #08e8f2;
  --stand-2: #4df3ff;

  --bg: #000000;
  --bg-elev: #1c1c1e;
  --bg-elev-2: #2c2c2e;
  --separator: rgba(84, 84, 88, 0.55);
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.62);
  --label-3: rgba(235, 235, 245, 0.32);
  --blue: #0a84ff;
  --orange: #ff9f0a;
  --yellow: #ffd60a;
  --purple: #bf5af2;
  --red: #ff453a;
  --green: #30d158;

  --radius-card: 18px;
  --radius-tile: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 52px;
  --tab-h: 58px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", Roboto, Helvetica, Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  overscroll-behavior-y: none;
}

body {
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
}
button { cursor: pointer; }
input, select, textarea { outline: none; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }

h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Navigation bar ---------- */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.2s ease;
}
.nav-bar.scrolled { border-bottom-color: var(--separator); }

.nav-inner {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  max-width: 720px;
  margin: 0 auto;
}

.nav-title {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  opacity: 0;
  transition: opacity 0.2s ease;
}
/* iOS-style: the compact title appears only once the large title scrolls away. */
.nav-bar.scrolled .nav-title { opacity: 1; }

.nav-action {
  color: var(--blue);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-inline-start: -6px;
}


.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  color: var(--label-2);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

/* ---------- Screen ---------- */
.screen {
  flex: 1;
  padding: 8px 16px calc(var(--tab-h) + var(--safe-bottom) + 28px);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  animation: screen-in 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

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

.large-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 6px 0 2px;
}
.subtitle {
  color: var(--label-2);
  font-size: 15px;
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 24px 0 10px;
}
.section-head h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.section-head a, .section-head button.link {
  color: var(--blue);
  font-size: 15px;
  font-weight: 500;
}

/* ---------- Tab bar ---------- */
.tab-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: start;
  gap: 2px;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(20, 20, 22, 0.82);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--separator);
}

.tab {
  height: var(--tab-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--label-3);
  font-size: 10px;
  font-weight: 600;
  transition: color 0.15s ease;
}
.tab svg { width: 25px; height: 25px; }
.tab[aria-selected="true"] { color: var(--move-2); }
.tab.tab-center[aria-selected="true"] { color: var(--label); }

.tab-fab {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--move-1), var(--move-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(250, 17, 79, 0.42);
}
.tab-fab svg { width: 19px; height: 19px; }

/* ---------- Sheet ---------- */
.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-root[hidden] { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #161618;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.6);
  animation: sheet-up 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: var(--safe-bottom);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

.sheet-grabber {
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: var(--label-3);
  margin: 8px auto 2px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px 10px;
}
.sheet-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.sheet-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  color: var(--label-2);
  display: grid;
  place-items: center;
}
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px 22px;
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  z-index: 90;
  inset-inline: 0;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(58, 58, 60, 0.95);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.24s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: 90vw;
  text-align: center;
}
.toast.leaving { animation: toast-out 0.22s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(0.97); } }

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