/* ============================================
   LINUS — Base Styles
   Reset, typography, layout foundation
   ============================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }

p {
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

a {
  color: var(--color-business);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-business-dark);
}

/* ---- Lists ---- */
ul, ol {
  list-style: none;
}

/* ---- Media ---- */
img, svg, canvas {
  display: block;
  max-width: 100%;
}

/* ---- Form Elements ---- */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* ---- Selection ---- */
::selection {
  background: var(--color-linus-1);
  color: var(--color-text-inverse);
}

/* ---- App Shell ---- */
.app {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background-color: var(--bg-primary);
}

/* ---- Views ---- */
.view {
  display: none;
  flex-direction: column;
  min-height: calc(100vh - var(--nav-height));
  min-height: calc(100dvh - var(--nav-height));
  padding: var(--space-xl) var(--space-lg) calc(var(--nav-height) + var(--space-xl) + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: viewFadeIn 350ms ease;
}

.view.active {
  display: flex;
}

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- View Headers ---- */
.view__header {
  margin-bottom: var(--space-2xl);
}

.view__title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-xs);
}

.view__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ---- Section ---- */
.section {
  margin-bottom: var(--space-2xl);
}

.section__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section__title-icon {
  font-size: var(--text-lg);
}

/* ---- Grid Utilities ---- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.flex-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.flex-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Text Utilities ---- */
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }

/* ---- Spacing Utilities ---- */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ---- Privacy Notice Overlay ---- */
.privacy-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-xl);
  animation: overlayFadeIn 300ms ease;
}

.privacy-overlay[hidden] {
  display: none;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.privacy-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-3xl) var(--space-2xl);
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.privacy-card h3 {
  margin-bottom: var(--space-lg);
}

.privacy-card p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-2xl);
  line-height: var(--leading-relaxed);
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: calc(100% - var(--space-3xl) * 2);
  max-width: 380px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  animation: toastSlideIn 350ms var(--transition-spring);
  pointer-events: auto;
}

.toast--success { border-left: 3px solid var(--color-success); }
.toast--error { border-left: 3px solid var(--color-danger); }
.toast--info { border-left: 3px solid var(--color-business); }

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---- Empty States ---- */
.empty-state {
  text-align: center;
  padding: var(--space-4xl) var(--space-xl);
  color: var(--color-text-muted);
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: var(--space-lg);
  opacity: 0.5;
}

.empty-state__text {
  font-size: var(--text-sm);
}

/* ---- Accessibility ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible for keyboard nav */
*:focus-visible {
  outline: 2px solid var(--color-linus-2);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Desktop breakpoint ---- */
@media (min-width: 768px) {
  .app {
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-xl);
    margin-top: var(--space-3xl);
    margin-bottom: var(--space-3xl);
    min-height: calc(100vh - var(--space-6xl));
    overflow: hidden;
  }
}
