/* ==========================================================================
   Alimenta Design System — Base, Atmosfera, Tipografia Editorial & Layout
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  background-color: var(--bg-app);
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-app);
  background-image: var(--bg-atmosphere);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.has-open-sheet {
  overflow: hidden;
}

h1, h2, h3, h4, p, ul, ol, figure, blockquote {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

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

a:hover {
  text-decoration: underline;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Shell mobile-first com recuo físico estilo Vaul ao abrir sheet */
.app-shell {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100dvh;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  transform-origin: 50% 24%;
  transition: transform var(--duration-drawer) var(--ease-drawer),
              opacity var(--duration-normal) var(--ease-out);
  will-change: transform;
}

body.has-open-sheet .app-shell {
  transform: scale(0.984);
  opacity: 0.92;
}

@media (min-width: 720px) {
  .app-shell {
    border-inline: 1px solid var(--border-hairline);
    box-shadow: var(--shadow-sm);
    background-color: var(--bg-app);
  }
}

.app-main {
  flex: 1 1 auto;
  padding: var(--space-4) var(--space-4) calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-8) + 12px);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.app-main:focus {
  outline: none;
}

.app-main.view-enter {
  animation: alimenta-view-enter var(--duration-normal) var(--ease-out);
}

/* Tipografia Editorial & Números Tabulares */
.tabular,
.grams,
.currency,
.days,
[data-tabular],
input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.display-title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 32;
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.kpi-value {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 32;
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.day-heading-title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 24;
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.h1, h1 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 28;
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.02em;
}

.h2, h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.h3, h3 {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.eyebrow {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.muted {
  color: var(--text-secondary);
}

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

.text-xs {
  font-size: var(--text-xs);
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 600;
}

/* Utilitários de layout */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

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

.stack-xs {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

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

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

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

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

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.flex-1 {
  flex: 1 1 0%;
  min-width: 0;
}

.divider {
  height: 1px;
  width: 100%;
  background-color: var(--border-hairline);
  border: 0;
}

/* Acessibilidade & alvos mínimos de toque (>= 44px) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.touch-target {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
}

/* Estado vazio amigável */
.empty-state {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

@keyframes alimenta-view-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@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;
  }

  body.has-open-sheet .app-shell {
    transform: none;
  }
}
