/* Shared "native app" feel for the hosted page, the landing page and the legal pages:
   pressed states, no tap flash, spinner, toast, reveals. Transform and opacity only. Colours come from tokens.css. */
:root {
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --sai-t: env(safe-area-inset-top, 0px);
  --sai-b: env(safe-area-inset-bottom, 0px);
  --sai-l: env(safe-area-inset-left, 0px);
  --sai-r: env(safe-area-inset-right, 0px);
}
html { -webkit-tap-highlight-color: transparent; overflow-wrap: break-word; }
body { -webkit-touch-callout: none; }
.hc-body, .prose, .src, input, textarea { -webkit-touch-callout: default; }
.col { padding-left: max(1.1rem, var(--sai-l)); padding-right: max(1.1rem, var(--sai-r)); }
.wrap { padding-left: max(1.25rem, var(--sai-l)); padding-right: max(1.25rem, var(--sai-r)); }

/* Everything tappable: no delay, no selection, no flash, eased release */
button, [role="button"], [role="radio"], summary, label.more, .btn, .icon-btn, .langs a, .rows a, select {
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
button, .btn, .icon-btn, summary, label.more, .langs a { -webkit-user-select: none; user-select: none; }
.btn, .icon-btn, .more, .stars button, .rows a, .langs a, .types li, .stick-title, .help summary {
  transition: transform 0.22s var(--ease), background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}
.btn:active, .icon-btn:active, .more:active, .stars button:active, .langs a:active, .stick-title:active {
  transform: scale(0.97); transition-duration: 0.06s;
}
.btn:active { background: #33373e; border-color: #33373e; }
[data-theme="dark"] .btn:active { background: #cfcbc0; border-color: #cfcbc0; }
.btn-ghost:active, .more:active { background: var(--paper-2); border-color: var(--ink-3); }
.btn-mark:active { background: #ffd400; }
.rows a:active, .help summary:active { opacity: 0.6; transition-duration: 0.06s; }
.btn:focus-visible, .icon-btn:focus-visible { outline-offset: 3px; }
.btn[disabled] { pointer-events: none; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border: 0; background: transparent; color: var(--ink); border-radius: 50%; padding: 0; cursor: pointer; }
.icon-btn:active { background: var(--paper-2); }
.icon-btn .ic { width: 1.4rem; height: 1.4rem; }

/* Inputs stay at 16 px (no iOS zoom) */
.input, .textarea, .select { font-size: 16px; transition: border-color 0.18s ease, box-shadow 0.18s ease; }

/* Busy button: label fades, spinner turns */
.btn.busy { position: relative; pointer-events: none; }
.btn.busy > * { opacity: 0; }
.btn.busy::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 1.3rem; height: 1.3rem; margin: -0.65rem 0 0 -0.65rem;
  border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(1.1rem + var(--sai-b)); z-index: 30; max-width: min(92vw, 28rem);
  padding: 0.8rem 1.15rem; border-radius: 999px; background: var(--ink); color: var(--paper);
  font-size: var(--fs-s); font-weight: 650; line-height: 1.25; text-align: center; box-shadow: 0 8px 28px rgba(21, 23, 26, 0.25);
  opacity: 0; transform: translate(-50%, 14px) scale(0.96); pointer-events: none;
  transition: opacity 0.2s ease, transform 0.28s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.err { background: var(--danger); color: #fff; }

/* Reveal on scroll: JS adds .rv only to things below the fold, then .in. Without JS nothing is ever hidden. */
.rv { opacity: 0; transform: translateY(12px); }
.rv.in { opacity: 1; transform: none; transition: opacity 0.4s ease, transform 0.5s var(--ease); }

/* Cross-fades and slide-ins */
.fade-out { opacity: 0; transform: translateY(-4px); transition: opacity 0.18s ease, transform 0.18s ease; pointer-events: none; }
.fade-in { animation: fadein 0.32s var(--ease) both; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.error:not([hidden]) { animation: slidein 0.24s var(--ease) both; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .rv { opacity: 1; transform: none; }
}
