/* PARU — calm phone OS. Chrome on Android first. */

@font-face {
  font-family: 'Sicarius Remake';
  src: url('/uploads/SicariusRemake-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #EEEAE1;
  --surface: #F7F4EE;
  --surface-2: #E4DFD4;
  --ink: #2B2E34;
  --ink-soft: #4A4F58;
  --muted: #7A7F88;
  --line: rgba(43, 46, 52, 0.12);
  --accent: #5E7A95;
  --accent-soft: rgba(94, 122, 149, 0.14);
  --danger: #A2564B;
  --tile: #3A3D44;
  --tile-ink: #EEEAE1;

  --radius: 18px;
  --tap: 48px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: 'Helvetica Neue', Helvetica, Arial, system-ui, sans-serif;
  --font-mark: 'Sicarius Remake', 'Helvetica Neue', sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191D;
    --surface: #212429;
    --surface-2: #2A2E34;
    --ink: #E6E2D9;
    --ink-soft: #C4C0B7;
    --muted: #8D929C;
    --line: rgba(230, 226, 217, 0.1);
    --accent: #8FA7BE;
    --accent-soft: rgba(143, 167, 190, 0.16);
    --danger: #D08A7F;
    --tile: #2C3036;
    --tile-ink: #E6E2D9;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  touch-action: manipulation;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}
/* 16px or more: Chrome does not zoom on focus */
input, textarea, select { font-size: 16px; }

button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Device frame ---------- */

#device {
  position: relative;
  width: 100%;
  height: 100vh;      /* fallback */
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

/* On wide screens, show PARU as a phone in the middle */
@media (min-width: 640px) and (min-height: 600px) {
  body {
    display: grid;
    place-items: center;
    background: var(--surface-2);
  }
  #device {
    width: 412px;
    height: min(880px, calc(100dvh - 48px));
    border-radius: 44px;
    box-shadow: 0 0 0 10px var(--tile), 0 30px 80px rgba(0, 0, 0, 0.22);
  }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 20px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 20px);
  overscroll-behavior: none;
}

/* ---------- Clock ---------- */

.clock-time {
  font-weight: 200;
  font-size: clamp(72px, 24vw, 104px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.clock-date {
  margin-top: 10px;
  font-size: 17px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ---------- Lock ---------- */

#lock {
  align-items: center;
  text-align: center;
  z-index: 3;
  background: var(--bg);
  touch-action: none;
  user-select: none;
  will-change: transform, opacity;
}
#lock.settling { transition: transform 0.35s var(--ease), opacity 0.35s var(--ease); }

.lock-top {
  margin-top: 8vh;
  margin-top: 8dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.lock-logo { display: block; }
.wordmark {
  font-family: var(--font-mark);
  font-size: 22px;
  letter-spacing: 0.28em;
  padding-left: 0.28em;
  color: var(--ink-soft);
}
.lock-clock { margin-top: 9vh; margin-top: 9dvh; }

.lock-open {
  margin-top: auto;
  margin-bottom: 8px;
  min-height: 72px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.02em;
  animation: nudge 3.2s ease-in-out infinite;
}
@keyframes nudge {
  0%, 70%, 100% { transform: translateY(0); }
  85% { transform: translateY(-5px); }
}

/* ---------- Home ---------- */

#home { z-index: 1; }
.home-clock { margin-top: 6vh; margin-top: 6dvh; padding-left: 4px; }
.home-clock .clock-time { font-size: clamp(64px, 20vw, 88px); }

.grid {
  margin-top: auto;
  margin-bottom: 28px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 26px 12px;
}
.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  min-height: var(--tap);
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.01em;
}
.app-icon .glyph {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 0.15s var(--ease), background 0.15s;
}
.app-icon:active .glyph { transform: scale(0.94); background: var(--surface-2); }
.app-icon.placeholder .glyph { color: var(--muted); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.app-icon.placeholder { color: var(--muted); }
.glyph svg { width: 28px; height: 28px; }

/* ---------- App layer ---------- */

#app {
  z-index: 2;
  background: var(--bg);
  padding-left: calc(var(--safe-l));
  padding-right: calc(var(--safe-r));
  padding-bottom: 0;
  opacity: 0;
  transform: scale(0.97) translateY(12px);
  transition: opacity 0.24s var(--ease), transform 0.28s var(--ease);
}
#app.open { opacity: 1; transform: none; }

.app-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: 0 8px;
  flex: none;
}
.app-title {
  flex: 1;
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-actions { display: flex; gap: 4px; }

.app-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 20px 24px;
  display: flex;
  flex-direction: column;
}

.home-bar {
  flex: none;
  height: calc(var(--safe-b) + 32px);
  min-height: var(--tap);
  width: 100%;
  border: 0;
  background: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14px;
  touch-action: none;
}
.home-bar span {
  width: 116px;
  height: 5px;
  border-radius: 3px;
  background: var(--ink);
  opacity: 0.35;
}

/* ---------- Shared controls ---------- */

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
}
.icon-btn:active { background: var(--accent-soft); }
.icon-btn svg { width: 22px; height: 22px; }

.btn {
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: 999px;
  border: 0;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.btn:active { background: var(--surface-2); }
.btn.primary { background: var(--tile); color: var(--tile-ink); box-shadow: none; }
.btn.accent { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; }

.field {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border-radius: 14px;
  border: 0;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 16px;
  outline: none;
}
.field:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.field::placeholder { color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }

.empty {
  margin: auto;
  padding: 40px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.note-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.row { display: flex; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

.section-label {
  margin: 24px 4px 8px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.segmented button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--tile); color: var(--tile-ink); }

/* ---------- Motion preferences ---------- */

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