/* NiMo Health — PWA styles.
 * Theme tokens are ported 1:1 from the Android app's ui/theme/Color.kt; component styles
 * reproduce the Jetpack Compose UI in ui/HomeScreen.kt and ui/PinScreens.kt. */

/* ---- variable fonts (both TTFs are true variable fonts: one face per family) ---- */
@font-face {
  font-family: "Hanken Grotesk";
  src: url("fonts/hanken_grotesk.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---- theme tokens (light) ---- */
:root,
:root[data-theme="light"] {
  --bg: #fdf5f3;
  --surface: #ffffff;
  --surface2: #faedec;
  --rose: #b4204e;
  --rose-strong: #94143d;
  --rose-container: #ffd9df;
  --on-rose-container: #5c0a25;
  --plum: #6c4a5e;
  --ink: #2c1a23;
  --muted: #927986;
  --faint: #b8a4ad;
  --line: rgba(108, 74, 94, 0.13);
  --shadow: rgba(124, 18, 46, 0.1);
  --shadow2: rgba(124, 18, 46, 0.16);
  --low: #9a8fa0;
  --low-bg: #efe9f1;
  --high: #d6863f;
  --high-bg: #fbe9d6;
  --peak: #b4204e;
  --peak-bg: #ffd9df;
}

/* ---- theme tokens (dark) ---- */
:root[data-theme="dark"] {
  --bg: #160d12;
  --surface: #221620;
  --surface2: #2c1d28;
  --rose: #ff90ac;
  --rose-strong: #ffaac0;
  --rose-container: #4e2030;
  --on-rose-container: #ffd9df;
  --plum: #caa6bb;
  --ink: #f4e7ec;
  --muted: #b294a3;
  --faint: #7c6470;
  --line: rgba(255, 200, 215, 0.12);
  --shadow: rgba(0, 0, 0, 0.45);
  --shadow2: rgba(0, 0, 0, 0.6);
  --low: #998ea0;
  --low-bg: #2b2330;
  --high: #e0a45a;
  --high-bg: #38291b;
  --peak: #ff90ac;
  --peak-bg: #4e2030;
}

/* ---- reset / base ---- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  /* prevent iOS rubber-band on the whole page; scroll happens inside .main */
  overscroll-behavior: none;
}
button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}
.serif {
  font-family: "Newsreader", Georgia, serif;
}
.hidden {
  display: none !important;
}

/* ---- app shell ---- */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 0;
  padding-top: calc(6px + env(safe-area-inset-top));
}
.topbar-title {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 21px;
  color: var(--ink);
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  flex: none;
}
.icon-btn svg {
  width: 21px;
  height: 21px;
}
.icon-btn--sm {
  width: 36px;
  height: 36px;
  color: var(--faint);
}
.icon-btn--sm svg {
  width: 18px;
  height: 18px;
}

/* ---- main scroll region ---- */
.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* ---- bottom nav ---- */
.tabbar {
  border-top: 1px solid var(--line);
  display: flex;
  padding: 9px 0 calc(7px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.nav-pill {
  width: 62px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--muted);
}
.nav-pill svg {
  width: 22px;
  height: 22px;
}
.nav-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}
.nav-item.active .nav-pill {
  background: var(--rose-container);
  color: var(--rose);
}
.nav-item.active .nav-label {
  color: var(--rose);
  font-weight: 700;
}

/* ---- pill tabs (Ovulation / Intimacy) ---- */
.pill-tabs {
  display: flex;
  margin: 14px 22px 6px;
  padding: 5px;
  border-radius: 30px;
  background: var(--surface2);
}
.pill {
  flex: 1;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
}
.pill.active {
  background: var(--surface);
  color: var(--rose);
}

/* ---- entry list ---- */
.list {
  padding: 10px 18px 120px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px 14px 14px 16px;
}
.badge {
  width: 50px;
  height: 50px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
  line-height: 1;
}
.card-body {
  flex: 1;
  min-width: 0;
}
.card-title {
  font-weight: 700;
  font-size: 16.5px;
}
.card-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}
.gap-chip {
  flex: none;
  background: var(--surface2);
  border-radius: 14px;
  padding: 7px 9px;
  text-align: center;
}
.gap-num {
  font-weight: 800;
  font-size: 16px;
  color: var(--plum);
  line-height: 1.1;
}
.gap-cap {
  font-weight: 700;
  font-size: 9px;
  color: var(--faint);
}
.gap-first {
  flex: none;
  text-align: center;
  padding: 7px 9px;
}
.gap-first .gap-num {
  color: var(--faint);
  font-size: 13px;
}

/* ---- empty state ---- */
.empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  text-align: center;
}
.empty-emoji {
  font-size: 62px;
  line-height: 1;
}
.empty-title {
  font-size: 22px;
  font-weight: 500;
  margin-top: 18px;
}
.empty-text {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 22px;
  margin-top: 8px;
  max-width: 230px;
}

/* ---- FAB ---- */
.fab {
  position: absolute;
  right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  height: 56px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 22px 0 20px;
  border-radius: 20px;
  background: var(--rose);
  color: #fff;
  font-weight: 700;
  font-size: 15.5px;
  box-shadow: 0 6px 20px var(--shadow2);
}
.fab svg {
  width: 20px;
  height: 20px;
}

/* ---- calendar ---- */
.calendar {
  padding: 8px 18px 24px;
}
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.cal-month {
  font-weight: 600;
  font-size: 19px;
}
.round-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface2);
  display: grid;
  place-items: center;
  color: var(--ink);
}
.round-btn svg {
  width: 24px;
  height: 24px;
}
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding-bottom: 6px;
}
.weekdays span {
  text-align: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--faint);
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.day-cell {
  height: 50px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1.5px solid transparent;
}
.day-cell.empty-cell {
  visibility: hidden;
}
.day-num {
  font-size: 14px;
  font-weight: 500;
}
.day-cell.today {
  border-color: var(--rose);
}
.day-cell.today .day-num {
  color: var(--rose);
  font-weight: 700;
}
.day-cell.selected {
  background: var(--rose-container);
  border-color: transparent;
}
.day-cell.selected .day-num {
  color: var(--on-rose-container);
  font-weight: 700;
}
.day-marks {
  height: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.heart-mark {
  font-size: 9px;
  color: var(--rose);
  line-height: 1;
}
.legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 16px 0 6px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
}
.legend-item .dot {
  width: 8px;
  height: 8px;
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 16px;
  margin-top: 8px;
}
.detail-title {
  font-weight: 600;
  font-size: 17.5px;
}
.detail-rows {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 14px;
}
.detail-empty {
  font-size: 14px;
  color: var(--muted);
  line-height: 21px;
  margin-top: 14px;
}
.detail-row {
  display: flex;
  align-items: center;
  gap: 13px;
}
.detail-row .badge {
  width: 42px;
  height: 42px;
  font-size: 21px;
}
.detail-row .card-title {
  font-size: 15.5px;
}
.detail-row .card-sub {
  font-size: 12.5px;
  margin-top: 2px;
}

/* ---- bottom sheet (add) ---- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
  animation: fade-in 0.18s ease;
}
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  padding: 0 24px calc(24px + env(safe-area-inset-bottom));
  z-index: 41;
  max-width: 560px;
  margin: 0 auto;
  animation: slide-up 0.24s cubic-bezier(0.2, 0, 0, 1);
  max-height: 92%;
  overflow-y: auto;
}
.sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin: 10px auto 0;
}
.sheet-title {
  font-weight: 600;
  font-size: 23px;
  padding: 6px 0 20px;
}
.sheet-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 9px;
}
.field-gap {
  height: 20px;
}
.date-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 50px;
  padding: 0 18px;
  border-radius: 16px;
  background: var(--surface2);
  border: 1px solid var(--line);
}
.date-row svg {
  width: 19px;
  height: 19px;
  color: var(--rose);
  flex: none;
}
.date-row .date-text {
  font-weight: 600;
  font-size: 15.5px;
}
/* the native date input overlays the row so a tap opens the OS picker */
.date-row input[type="date"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}
.chips {
  display: flex;
  gap: 9px;
}
.time-chip {
  flex: 1;
  height: 42px;
  border-radius: 21px;
  background: var(--surface2);
  border: 1.5px solid var(--line);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
}
.time-chip.active {
  background: var(--rose);
  border-color: var(--rose);
  color: #fff;
}
.result-chips {
  display: flex;
  gap: 11px;
}
.result-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 0;
  border-radius: 18px;
  background: var(--surface2);
  border: 1.5px solid var(--line);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.result-chip .res-emoji {
  font-size: 26px;
  line-height: 1;
}
/* active result chip — colors come from --chip-bg/--chip-fg set inline per result */
.result-chip.active {
  background: var(--chip-bg);
  border-color: var(--chip-fg);
  color: var(--chip-fg);
}
.btn-primary {
  width: 100%;
  height: 54px;
  border-radius: 18px;
  background: var(--rose);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  margin-top: 26px;
}
.btn-primary:disabled {
  background: var(--surface2);
  color: var(--faint);
  cursor: default;
}

/* ---- dialog (delete confirm) ---- */
.dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 48px);
  max-width: 420px;
  background: var(--surface);
  border-radius: 28px;
  padding: 24px;
  z-index: 51;
  animation: pop-in 0.16s ease;
}
.dialog-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--rose-container);
  display: grid;
  place-items: center;
  color: var(--rose);
}
.dialog-icon svg {
  width: 24px;
  height: 24px;
}
.dialog-title {
  font-weight: 600;
  font-size: 21px;
  margin-top: 16px;
}
.dialog-text {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 21px;
  margin-top: 7px;
}
.dialog-actions {
  display: flex;
  gap: 11px;
  margin-top: 22px;
}
.btn-outline,
.btn-danger {
  flex: 1;
  height: 50px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 15px;
  display: grid;
  place-items: center;
}
.btn-outline {
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-danger {
  background: var(--rose);
  color: #fff;
  font-weight: 700;
}

/* ---- full-screen states: auth / denied / pin ---- */
.fullscreen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 60;
  padding: calc(28px + env(safe-area-inset-top)) 34px
    calc(28px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}
.fs-center {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.logo {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: var(--rose-container);
  display: grid;
  place-items: center;
  color: var(--rose);
}
.logo svg {
  width: 30px;
  height: 30px;
}
.fs-title {
  font-size: 30px;
  font-weight: 500;
  color: var(--ink);
  margin-top: 26px;
}
.fs-sub {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 21px;
  margin-top: 9px;
  max-width: 260px;
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  height: 52px;
  padding: 0 22px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  font-size: 15.5px;
  margin-top: 32px;
  box-shadow: 0 4px 14px var(--shadow);
}
.btn-google svg {
  width: 20px;
  height: 20px;
}
.link-btn {
  font-size: 12.5px;
  color: var(--faint);
  padding: 8px;
  border-radius: 8px;
  margin-top: 18px;
}
.denied-email {
  font-weight: 700;
  color: var(--ink);
}

/* ---- PIN screen ---- */
.pin-dots {
  display: flex;
  gap: 18px;
  margin-top: 38px;
}
.pin-dots.shake {
  animation: shake 0.4s ease;
}
.pin-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--faint);
}
.pin-dot.filled {
  background: var(--rose);
  border-color: var(--rose);
}
.pin-error {
  height: 22px;
  margin-top: 14px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--rose);
}
.keypad {
  width: 268px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 26px;
}
.key {
  height: 66px;
  border-radius: 50%;
  font-weight: 500;
  font-size: 27px;
  color: var(--ink);
  display: grid;
  place-items: center;
}
.key.blank {
  pointer-events: none;
}

/* ---- animations ---- */
@keyframes blink {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.32;
  }
}
.blink {
  animation: blink 0.65s ease-in-out infinite alternate;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
}
@keyframes pop-in {
  from {
    transform: translate(-50%, -50%) scale(0.94);
    opacity: 0;
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-9px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(4px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .blink,
  .pin-dots.shake,
  .scrim,
  .sheet,
  .dialog {
    animation: none;
  }
}
