/* ZEVx design system, shared by every page.
   Page-specific styles stay inline in each page. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --hairline: rgba(0, 0, 0, 0.1);
  --link: #0066cc;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-text: #ffffff;
  --accent-gradient: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 55%, #bf5af2 100%);
  --error: #e30000;
  --success: #34c759;
  --nav-bg: rgba(251, 251, 253, 0.8);
  --glass: rgba(255, 255, 255, 0.72);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-lift: 0 12px 40px rgba(0, 0, 0, 0.12);
  --focus: 0 0 0 4px rgba(0, 113, 227, 0.3);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* Theme choice (theme.js): data-theme="light|dark" on <html> forces one;
   with no attribute the device decides through the media query. */
:root[data-theme="light"] {
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-alt: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --faint: #86868b;
    --hairline: rgba(255, 255, 255, 0.12);
    --link: #2997ff;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --error: #ff453a;
    --success: #30d158;
    --nav-bg: rgba(22, 22, 23, 0.8);
    --glass: rgba(44, 44, 46, 0.72);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    --shadow-lift: 0 12px 40px rgba(0, 0, 0, 0.6);
    --focus: 0 0 0 4px rgba(41, 151, 255, 0.4);
  }
}
:root[data-theme="dark"] {
    --bg: #000000;
    --bg-alt: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --faint: #86868b;
    --hairline: rgba(255, 255, 255, 0.12);
    --link: #2997ff;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --error: #ff453a;
    --success: #30d158;
    --nav-bg: rgba(22, 22, 23, 0.8);
    --glass: rgba(44, 44, 46, 0.72);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    --shadow-lift: 0 12px 40px rgba(0, 0, 0, 0.6);
    --focus: 0 0 0 4px rgba(41, 151, 255, 0.4);
}

/* --- Base --- */

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  /* Three soft brand glows at the top of every page, light and dark alike. */
  background:
    radial-gradient(60% 420px at 30% 0%, rgba(10, 132, 255, 0.16), transparent 70%),
    radial-gradient(50% 380px at 75% 8%, rgba(94, 92, 230, 0.14), transparent 70%),
    radial-gradient(40% 340px at 92% 0%, rgba(191, 90, 242, 0.12), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.app {
  background: var(--bg-alt);
}
a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
::selection {
  background: rgba(0, 113, 227, 0.25);
}

/* --- Navigation: a frosted glass bar pinned to the top --- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
  /* Clears the iPhone status bar and Dynamic Island (needs viewport-fit=cover) */
  padding-top: env(safe-area-inset-top);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 980px;
  min-height: 48px;
  margin: 0 auto;
  padding: 0 16px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.nav-brand:hover {
  text-decoration: none;
}
.nav-brand svg {
  width: 22px;
  height: 22px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 13px;
  letter-spacing: -0.01em;
}
.nav-links a {
  color: var(--muted);
  transition: color 0.2s var(--ease);
}
.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}
.nav-links a[aria-current="page"] {
  color: var(--text);
}

/* Signed in: the Profile link is your avatar and a Settings gear sits
   beside it. nav-user.js swaps these in. */
.nav-links .nav-avatar {
  display: grid;
  place-content: center;
  width: 28px;
  height: 28px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  color: #ffffff;
  background: var(--accent-gradient);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(94, 92, 230, 0.3);
}
.nav-links .nav-avatar:hover {
  color: #ffffff;
}
.nav-links .nav-avatar[aria-current="page"] {
  color: #ffffff;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px #0071e3;
}
.nav-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.nav-links .nav-gear {
  display: grid;
  place-content: center;
  width: 28px;
  height: 28px;
  color: var(--muted);
  background: var(--bg-alt);
  border-radius: 50%;
}
.nav-links .nav-gear:hover {
  color: var(--text);
}
.nav-gear svg {
  width: 15px;
  height: 15px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nav-links .nav-gear {
    background: #2c2c2e;
  }
}
:root[data-theme="dark"] .nav-links .nav-gear {
  background: #2c2c2e;
}

/* Narrow phones: tighter link spacing, and wrap rather than overflow */
@media (max-width: 480px) {
  .nav-inner {
    gap: 12px;
  }
  .nav-links {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px 14px;
    padding: 8px 0;
  }
}

/* --- Inside the iOS app: a native tab bar replaces the nav (see native.js) --- */

.in-app .nav {
  display: none;
}
.in-app body {
  /* With the nav gone, clear the status bar ourselves */
  padding-top: env(safe-area-inset-top);
}
.in-app .page {
  /* Keep the end of the content above the tab bar and home indicator */
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* --- Layout and type --- */

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 64px 16px 96px;
}
.page.narrow {
  max-width: 692px;
}
.page-header {
  margin-bottom: 40px;
  text-align: center;
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.headline {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.subhead {
  max-width: 34em;
  margin: 12px auto 0;
  font-size: clamp(19px, 2.4vw, 24px);
  font-weight: 400;
  line-height: 1.35;
  color: var(--muted);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* --- Cards --- */

.card {
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}

/* --- Buttons --- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 22px;
  font: inherit;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.022em;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 980px;
  cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
}
.button:hover {
  background: var(--accent-hover);
  text-decoration: none;
}
.button:active {
  transform: scale(0.97);
}
.button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.button.secondary {
  color: var(--link);
  background: transparent;
  border-color: var(--link);
}
.button.secondary:hover {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}
.text-button {
  padding: 0;
  font: inherit;
  color: var(--link);
  background: none;
  border: none;
  cursor: pointer;
}
.text-button:hover {
  text-decoration: underline;
}
/* "Log out" never wraps or shrinks, however tight the row gets */
#logout.text-button {
  flex: none;
  white-space: nowrap;
}
.chevron::after {
  content: " ›";
}

/* --- Inputs --- */

.field {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field::placeholder {
  color: var(--faint);
}
.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

/* --- Messages --- */

.message {
  min-height: 1.5em;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.message.error {
  color: var(--error);
}
.message:empty {
  min-height: 0;
  margin: 0;
}

/* --- Entrance: content fades and rises in, a beat apart --- */

.reveal {
  animation: reveal 0.9s var(--ease) both;
}
.reveal:nth-child(2) { animation-delay: 0.08s; }
.reveal:nth-child(3) { animation-delay: 0.16s; }
.reveal:nth-child(4) { animation-delay: 0.24s; }
.reveal:nth-child(5) { animation-delay: 0.32s; }
@keyframes reveal {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    animation: none;
  }
  .button,
  .field,
  .nav-links a {
    transition: none;
  }
}

/* --- Quote band: a rotating quote just below the nav (see quote.js) --- */

.quote-band {
  position: relative;
  padding: 36px 16px 34px;
  text-align: center;
  border-bottom: 1px solid var(--hairline);
}
.quote {
  max-width: 820px;
  margin: 0 auto;
  cursor: pointer;
  transition: opacity 0.6s var(--ease), filter 0.6s var(--ease), transform 0.6s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.quote.out {
  opacity: 0;
  filter: blur(8px);
  transform: translateY(8px) scale(0.99);
}
.quote:focus-visible {
  outline: none;
  border-radius: 12px;
  box-shadow: var(--focus);
}
.quote-text {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: clamp(20px, 2.6vw, 28px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.025em;
  text-wrap: balance;
  /* Ink that fades softly toward the end, like Apple's keynote type */
  background: linear-gradient(100deg, var(--text) 40%, var(--muted) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.quote-author {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.quote-author::before {
  content: "— ";
}
/* A hairline that fills while the quote is up, then the next one fades in */
.quote-progress {
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 96px;
  height: 2px;
  overflow: hidden;
  background: var(--hairline);
  border-radius: 2px;
  transform: translateX(-50%);
}
.quote-progress span {
  display: block;
  height: 100%;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transform-origin: left;
}
.quote-progress span.run {
  animation: quote-progress var(--quote-seconds, 12s) linear forwards;
}
.quote-band:hover .quote-progress span,
.quote-band:focus-within .quote-progress span {
  animation-play-state: paused;
}
@keyframes quote-progress {
  to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  .quote {
    transition: none;
  }
  .quote-progress {
    display: none;
  }
}

/* --- Swipe to delete: a red button behind a list row (see swipe.js) --- */

.swipe-row {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.swipe-front {
  position: relative;
  z-index: 1;
  background: var(--surface);
  touch-action: pan-y;
  transition: transform 0.3s var(--ease);
}
.swipe-row > .swipe-delete {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 88px;
  height: 100%;
  padding: 0;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  background: var(--error);
  border: none;
  border-radius: 0;
  opacity: 1;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .swipe-front {
    transition: none;
  }
}
