/*
 * ClawPad PWA — Base Styles
 * Reset, typography, global layout, safe-area handling.
 */

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--gradient-body, var(--bg));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  touch-action: manipulation;
  overscroll-behavior-y: contain;
  /* Safe area padding */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Selection styling */
::selection {
  background: var(--selection-bg);
  color: var(--ink);
}
::-moz-selection {
  background: var(--selection-bg);
  color: var(--ink);
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.page-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* Scrollbar — thin, themed */
.page-container::-webkit-scrollbar {
  width: 4px;
}
.page-container::-webkit-scrollbar-track {
  background: transparent;
}
.page-container::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
h1 {
  font-size: 22px;
  letter-spacing: -0.02em;
}
h2 { font-size: 18px; }
h3 { font-size: 16px; }

code, pre {
  font-family: 'IBM Plex Mono', 'SFMono-Regular', 'Consolas', monospace;
  font-size: 13px;
}

pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

a {
  color: var(--brand);
  text-decoration: none;
}

/* Focus-visible — gold ring for keyboard users */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Remove tap highlight on mobile */
button, a, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

/* Utility classes */
.hidden { display: none !important; }
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.text-muted { color: var(--ink-muted); }
.text-soft { color: var(--ink-soft); }
.text-brand { color: var(--brand); }

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Branded spinner — gradient */
.spinner-branded {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(242, 201, 76, 0.15);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Fade in animation */
.fade-in {
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Offline banner */
.offline-banner {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  padding: 8px 16px;
  background: var(--warn);
  color: var(--ink-on-brand);
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  transition: transform 0.3s ease;
}
.offline-banner.hidden {
  transform: translateY(-100%);
}
