/* Phones, folding phones and tablets only (2026-11-26).
   device.js tags <html> with data-device = phone | fold | tablet | desktop. Every rule here starts with one of those tags,
   so a computer (data-device="desktop") never sees any of it: the desktop layout stays exactly as it is.
   Motion follows a few plain rules: quick (under 300 ms), eased in and out, starts where the finger is, can be interrupted,
   and the things people tap all day move the least. motion.js adds the ripple, the loading bar and the first-visit fade. */

/* ---------- 1. Touch feel: press down where you tap (squash, origin, interruptible) */
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) {
  -webkit-tap-highlight-color: transparent;
  --ease-out: cubic-bezier(.22, 1, .36, 1);       /* slow out: settles gently */
  --ease-io: cubic-bezier(.65, 0, .35, 1);        /* slow in, slow out */
}
/* no hover lift on touch screens (it sticks after a tap), a short press-in instead, then a soft spring back */
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) .btn:hover { transform: none; box-shadow: none; }
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) .btn {
  position: relative; overflow: hidden; isolation: isolate;
  transition: transform .22s var(--ease-out), background-color .15s, box-shadow .15s; }
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) .btn:active { transform: scale(.97); transition-duration: .08s; }
/* cards and rows that act as links: a smaller press (they're tapped more often, so they move less) */
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) :is(.check-list a, .stack .card, .reel > a, .ledger tr[data-href], .choices label) {
  transition: transform .22s var(--ease-out), border-color .15s, background .15s; }
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) :is(.check-list a, .stack .card, .reel > a, .ledger tr[data-href], .choices label):active {
  transform: scale(.985); transition-duration: .08s; }

/* the ripple motion.js puts inside a tapped button: grows from the tap point, fades as it lands */
.pn-ripple { position: absolute; z-index: -1; left: var(--rx); top: var(--ry); width: var(--rs); height: var(--rs); margin: calc(var(--rs) / -2) 0 0 calc(var(--rs) / -2);
  border-radius: 50%; background: currentColor; opacity: .16; transform: scale(0); pointer-events: none;
  animation: pn-ripple .42s cubic-bezier(.22, 1, .36, 1) forwards; }
@keyframes pn-ripple { 60% { opacity: .12; } to { transform: scale(1); opacity: 0; } }

/* tab bar: the tapped icon dips and comes back (the most used control, so the smallest motion) */
html:is([data-device="phone"], [data-device="fold"]) .tabbar a { transition: color .15s; }
html:is([data-device="phone"], [data-device="fold"]) .tabbar a svg { transition: transform .22s var(--ease-out); }
html:is([data-device="phone"], [data-device="fold"]) .tabbar a:active svg { transform: scale(.88); transition-duration: .08s; }
html:is([data-device="phone"], [data-device="fold"]) .tabbar .snapbtn span.c { transition: transform .22s var(--ease-out); }
html:is([data-device="phone"], [data-device="fold"]) .tabbar .snapbtn:active span.c { transform: scale(.92); transition-duration: .08s; }

/* ---------- 2. Easy to hit: 44 pt targets, readable text */
html:is([data-device="phone"], [data-device="fold"]) .btn.sm,
html:is([data-device="phone"], [data-device="fold"]) .btn.ghost { min-height: 44px; }
html:is([data-device="phone"], [data-device="fold"]) .seg label { min-height: 44px; display: inline-flex; align-items: center; }
html:is([data-device="phone"], [data-device="fold"]) :is(input, select, textarea) { font-size: max(16px, 1em); } /* iPhone zooms into anything smaller */
html[data-device="phone"] .tabbar a { font-size: 11px; }
/* month-by-month bars: all 12 months fit across a phone (they spilled past the card before) */
html[data-device="phone"] .bars { gap: 3px; grid-auto-columns: minmax(0, 1fr); }
html[data-device="phone"] .bars .lbl { font-size: 10.5px; letter-spacing: -.01em; }

/* sideways scrollers (tabs, wide tables) snap and keep their bounce to themselves, so the page doesn't shift */
html:is([data-device="phone"], [data-device="fold"]) :is(.lp-tabs, .lp-cmp-tabs, .table-wrap, .ledger-wrap, .tabs) { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
html:is([data-device="phone"], [data-device="fold"]) :is(.lp-tabs, .lp-cmp-tabs) { scroll-snap-type: x proximity; scroll-padding-inline: 16px; }
html:is([data-device="phone"], [data-device="fold"]) :is(.lp-tabs, .lp-cmp-tabs) > * { scroll-snap-align: start; }

/* ---------- 3. Help bubble: just the coin on a phone, so it never sits on top of a button or a figure */
html[data-device="phone"] .hc { right: 14px; }
html[data-device="phone"] .hc-launch { padding: 7px; gap: 0; box-shadow: 0 8px 22px -8px rgba(0,0,0,.45); }
html[data-device="phone"] .hc-launch > span:not(.mascot):not(.hc-new):not(.hc-count) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html[data-device="phone"] .hc-launch .mascot { width: 34px; height: 34px; }
html[data-device="phone"] .hc-launch { transition: transform .22s var(--ease-out); }
html[data-device="phone"] .hc-launch:active { transform: scale(.92); transition-duration: .08s; }
/* while you scroll down to read, the coin slides off to the side; it comes back as soon as you scroll up or reach the
   end (motion.js), and the page keeps enough room at the bottom for its last line to clear both the coin and the tab bar */
html[data-device="phone"] .hc:not(.is-open) { transition: transform .26s var(--ease-out), opacity .2s var(--ease-out); }
html[data-device="phone"] .hc.pn-tuck:not(.is-open) { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
/* resting over a table: only the coin's edge peeks out so the figures stay readable; a tap still opens help */
html[data-device="phone"] .hc.pn-peek:not(.is-open):not(.pn-tuck) { transform: translateX(calc(100% - 12px)); }
html[data-device="phone"] .hc.pn-peek:not(.is-open) .hc-new { opacity: 0; }
html[data-device="phone"] .shell main { padding-bottom: calc(180px + env(safe-area-inset-bottom)); }
/* the panel opens from the bubble's corner, not from nowhere */
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) .hc.is-open .hc-panel { transform-origin: 100% 100%; animation: pn-pop .24s var(--ease-out) both; }
@keyframes pn-pop { from { opacity: 0; transform: scale(.92) translateY(8px); } }
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) .hc-panel:focus { outline: none; }

/* ---------- 4. Notes from Pennify: a toast drops in with a little overshoot, then gets out of the way */
html:is([data-device="phone"], [data-device="fold"]) .toasts { top: calc(10px + env(safe-area-inset-top)); }
html:is([data-device="phone"], [data-device="fold"]) .toast { max-width: none; text-align: center; transform-origin: 50% 0;
  animation: pn-toast-in .32s cubic-bezier(.34, 1.4, .64, 1) both, toastOut .3s 4.2s var(--ease-io) forwards; }
@keyframes pn-toast-in { from { opacity: 0; transform: translateY(-14px) scale(.94); } }

/* ---------- 5. Loading bar: shows only when a page takes longer than a blink, so fast pages never flash it */
.pn-bar { position: fixed; z-index: 120; left: 0; top: 0; height: 3px; width: 100%; background: var(--lime, #C3F98A);
  transform-origin: 0 50%; transform: scaleX(0); opacity: 0; pointer-events: none; box-shadow: 0 0 8px rgba(195,249,138,.6); }
.pn-bar.go { opacity: 1; transform: scaleX(.82); transition: transform 2.4s cubic-bezier(.1, .7, .2, 1), opacity .12s; }
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) .pn-bar { top: env(safe-area-inset-top); }

/* ---------- 6. First visit of a page in a session: its blocks rise in one after another (device.js sets pn-enter).
   Later visits of the same page: no motion at all, because a page you open every day shouldn't make you wait. */
html.pn-enter main > * { animation: pn-rise .28s var(--ease-out, ease-out) both; }
html.pn-enter main > :nth-child(2) { animation-delay: 40ms; }
html.pn-enter main > :nth-child(3) { animation-delay: 80ms; }
html.pn-enter main > :nth-child(4) { animation-delay: 120ms; }
html.pn-enter main > :nth-child(n+5) { animation-delay: 160ms; }
@keyframes pn-rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- 7. Front page on a phone */
/* "Create an account": once the hero's own button has scrolled away, a small lime button takes the place of "Log in"
   in the header (it grows in from the right, where it sits). Not a bar stuck to the bottom: Safari would paint its own
   bottom bar lime to match it. */
html:is([data-device="phone"], [data-device="fold"]) .lp-sticky { display: none; }
html:is([data-device="phone"], [data-device="fold"]) .lp-acct { position: relative; display: flex; align-items: center; }
html:is([data-device="phone"], [data-device="fold"]) .lp .lp-top .btn.lp-sm { display: inline-flex; position: absolute; right: 0; top: 50%;
  height: 40px; padding: 0 16px; font-size: 14.5px; white-space: nowrap; transform-origin: 100% 50%;
  transform: translateY(-50%) scale(.85); opacity: 0; pointer-events: none; visibility: hidden;
  transition: transform .24s var(--ease-out), opacity .16s, visibility 0s .24s; }
html:is([data-device="phone"], [data-device="fold"]) :is(.lp-login, .lp-lang) { transition: opacity .16s, transform .24s var(--ease-out); }
html:is([data-device="phone"], [data-device="fold"]) .lp-top.cta :is(.lp-login, .lp-lang) { opacity: 0; transform: translateX(8px); pointer-events: none; }
html:is([data-device="phone"], [data-device="fold"]) .lp-top.cta .btn.lp-sm { transform: translateY(-50%); opacity: 1; pointer-events: auto; visibility: visible;
  transition: transform .24s var(--ease-out), opacity .16s, visibility 0s; }
html:is([data-device="phone"], [data-device="fold"]) .lp-top.cta .btn.lp-sm:active { transform: translateY(-50%) scale(.97); }
/* the phone picture in the hero: smaller, so the promise and the button come first */
html[data-device="phone"] .lp-phone { width: min(220px, 62vw); margin-inline: auto; }
/* plans: swipe sideways through them, one and a bit on screen, each one snapping into place */
html[data-device="phone"] .lp-pgrid { display: flex; overflow-x: auto; gap: 14px; scroll-snap-type: x mandatory; scroll-padding-inline: 16px;
  margin-inline: -16px; padding: 4px 16px 18px; overscroll-behavior-x: contain; scrollbar-width: none; }
html[data-device="phone"] .lp-pgrid::-webkit-scrollbar { display: none; }
html[data-device="phone"] .lp-pgrid > * { flex: 0 0 86%; scroll-snap-align: start; }
html[data-device="phone"] .lp-foot { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

/* ---------- 8. Folding phones and tablets: use the extra width, keep clear of the hinge */
html[data-device="fold"] main { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
html[data-device="fold"] :is(.reel) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
html[data-device="fold"][data-orient="landscape"] :is(.cols-2, .split) { grid-template-columns: 1fr 1fr; }
/* a page shown across the hinge: two halves with the fold as the gap between them */
html[data-split="y"] :is(.cols-2, .split, .lp-hero-in, .lp-split) { grid-template-columns: 1fr 1fr;
  column-gap: calc(env(viewport-segment-left 1 0, 50vw) - env(viewport-segment-right 0 0, 50vw) + 32px); }
html[data-device="tablet"] .reel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
html[data-device="tablet"][data-orient="landscape"] .reel { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- 9. Edges of the screen: nothing under the notch, the home bar or a rounded corner */
html:is([data-device="phone"], [data-device="fold"]) .mobile-top { padding-top: max(14px, env(safe-area-inset-top)); }
html[data-device="phone"][data-orient="landscape"] :is(main, .mobile-top, .lp-wrap) {
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
/* log-in, sign-up, error and legal pages: Safari paints its status bar and bottom bar in one solid colour, the page's
   base colour. The page's own gradient fades into that same colour at its top and bottom edges, so the bars read as part
   of the page instead of a flat band with a hard edge (iPhone 17 simulator, 2026-11-26). Nothing is added on top. */
html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) .auth-body::before {
  background:
    linear-gradient(#191918 env(safe-area-inset-top), rgba(25,25,24,0) calc(env(safe-area-inset-top) + 64px)),
    linear-gradient(to top, #191918 calc(env(safe-area-inset-bottom) + 66px), rgba(25,25,24,0) calc(env(safe-area-inset-bottom) + 180px)),
    radial-gradient(55% 60% at 88% 0%, rgba(195,249,138,.16) 0%, rgba(195,249,138,0) 70%),
    radial-gradient(50% 60% at 0% 100%, rgba(195,186,244,.20) 0%, rgba(195,186,244,0) 70%),
    radial-gradient(rgba(245,245,238,.075) 1px, transparent 1.3px) 0 0 / 22px 22px,
    #191918; }
@media (prefers-color-scheme: light) {
  html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) .auth-body::before {
    background:
      linear-gradient(#7233C9 env(safe-area-inset-top), rgba(114,51,201,0) calc(env(safe-area-inset-top) + 64px)),
      linear-gradient(to top, #7233C9 calc(env(safe-area-inset-bottom) + 66px), rgba(114,51,201,0) calc(env(safe-area-inset-bottom) + 180px)),
      var(--pp);
    background-color: #7233C9; }
}

/* ---------- 10. Anyone who asked their phone for less motion gets none of it */
@media (prefers-reduced-motion: reduce) {
  .pn-ripple, .pn-bar { display: none !important; }
  html.pn-enter main > * { animation: none !important; }
  html:is([data-device="phone"], [data-device="fold"], [data-device="tablet"]) :is(.btn, .tabbar a svg, .hc-launch):active { transform: none; }
  html:is([data-device="phone"], [data-device="fold"]) :is(.lp .lp-top .btn.lp-sm, .lp-login, .lp-lang, .hc) { transition: none; }
}
