/* ══════════════════════════════════════
   Porter Settings — styles.css

   Tokens (color, type scale, spacing, radius, fonts, motion, z-index) come from
   /shared/porter-tokens.css, linked in <head> before this file. This sheet keeps
   only components, built from those tokens.

   Design language: Sky+Mint theme. Display serif (Fraunces) for chrome titles,
   mono (IBM Plex Mono) for small uppercase labels, sans (IBM Plex Sans) for body.
   ══════════════════════════════════════ */

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; }       /* horizontal-scroll backstop */
/* "Steel, not plastic": reserve the scrollbar gutter so a tall page never
   narrows the viewport and reflows the layout when the scrollbar appears. */
html { scrollbar-gutter: stable; -webkit-font-smoothing: antialiased; }

/* --hdr-h is the fixed-header height the body reserves via padding-top. */
:root { --hdr-h: 54px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-weight: 300;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  padding-top: calc(var(--hdr-h) + env(safe-area-inset-top));
}

/* ── Header ──
   Fixed (pinned) — position:sticky would be killed by the html/body
   overflow-x:hidden, so the header is fixed and body reserves --hdr-h. */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-lg);
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-sticky);
  padding-top: env(safe-area-inset-top);
}
.header-left { display: flex; align-items: center; gap: var(--space-sm); }
.back-link {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 400;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--motion-base);
  flex-shrink: 0;
}
.back-link:hover { color: var(--steel); }
.header-divider {
  width: 1px;
  height: 1.2em;
  background: var(--border);
  flex-shrink: 0;
  align-self: center;
}
/* Settings is Porter-level chrome, not an app with a signature hue: its
   header glyph and accents read neutral steel. */
.app-header-icon {
  width: 1.15em;
  height: 1.15em;
  color: var(--steel);
  flex-shrink: 0;
}
/* Mini-caps serif: the chrome-header treatment (app title + card/modal titles). */
.app-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text);
}

/* ── Page shell ── */
.settings-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ── Cards ── */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.settings-card-hd {
  padding: var(--space-md) var(--space-lg) var(--space-sm);
  border-bottom: 1px solid var(--border);
}
/* Card title — mini-caps serif chrome header. */
.settings-card-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: var(--space-xs);
}
.settings-card-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.6;
}
.settings-card-body {
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* ── Backup status line ── (mono — it holds a date/figure) */
.backup-status {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-muted);
}
.backup-status.is-stale { color: var(--text-dim); }
.backup-status.is-error { color: var(--danger); }

/* ── Action row ── */
.settings-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ── Buttons ── (secondary shape: transparent surface, accent on hover) */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-head);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--ls-title);
  text-transform: uppercase;
  transition: all var(--motion-fast);
}
.btn:hover { background: var(--steel-tint); border-color: var(--steel-dim); color: var(--steel); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface-2); border-color: var(--border); color: var(--text-muted); }
.btn svg { flex-shrink: 0; }
.btn-danger-hover:hover {
  background: var(--danger-tint);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger {
  background: var(--danger-tint);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: var(--bg);
  border-color: var(--danger);
}

/* ── Modal ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  z-index: var(--z-overlay);
}
.overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
}
.modal-hd {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* Modal title — mini-caps serif chrome header. */
.modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}
.modal-x {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--fs-lg);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-x:hover { color: var(--text); }
.modal-body {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.modal-body p { font-size: var(--fs-md); line-height: 1.55; }
.modal-body p.muted { color: var(--text-muted); font-size: var(--fs-sm); }
.modal-body strong { font-weight: 500; color: var(--text); }
.modal-ft {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--steel-dim);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--fs-sm);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  z-index: var(--z-toast);
  max-width: calc(100vw - 2rem);
}
.toast[hidden] { display: none; }

/* ── Footer ── always present (margin-top:auto pins it to the bottom of the
   flex column). Version first, then byline; quiet muted mono, top border. */
.app-footer {
  margin-top: auto;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: .4px;
  color: var(--text-dim);
  opacity: 0.7;
  padding: var(--space-lg) var(--space-md) calc(var(--space-lg) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.app-footer .sep { opacity: 0.5; margin: 0 7px; }

/* ── Mobile ── size knob + tightened padding. */
@media (max-width: 600px) {
  html { font-size: 15px; }
  .settings-shell { padding: var(--space-md) var(--space-sm) var(--space-xl); }
  .settings-card-hd, .settings-card-body { padding-left: var(--space-md); padding-right: var(--space-md); }
  .app-header { padding: 0 var(--space-md); }
}
