/* Glow da Clara — base e shell (P1) */

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--perola);
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  color: var(--ui-text);
  background: var(--ui-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font-variant-numeric: lining-nums;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: var(--lh-tight); }
ul[class], ol[class] { margin: 0; padding: 0; list-style: none; }

img, video, canvas { display: block; max-width: 100%; }
svg { flex-shrink: 0; vertical-align: middle; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  text-align: inherit;
}
button:disabled { cursor: default; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
[hidden] { display: none !important; }

/* controles não selecionam texto nem abrem a lupa do iOS */
button, [role="button"], label, nav, .btn, .chip, .segmented, .stepper,
.list-item, .card-tap, .option-card, .nav-item {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

/* foco visível só para teclado (teclado externo do iPad) */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--ui-ring);
  outline-offset: 2px;
}

::selection { background: var(--rose-suave); color: var(--vinho); }

/* tema escuro aplicado a um contêiner */
[data-theme="dark"] {
  background-color: var(--ui-bg);
  color: var(--ui-text);
}

/* ---------- shell ---------- */
#app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: calc(var(--nav-size) + var(--safe-l)) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  /* quanto a navegação ocupa embaixo (para .fab e afins) e quanta área segura a tela precisa embaixo */
  --nav-offset-b: 0px;
  --view-safe-b: var(--safe-b);
  background: var(--ui-bg);
}

#view {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background:
    radial-gradient(70% 45% at 100% 0%, color-mix(in srgb, var(--rose-suave) 70%, transparent), transparent 70%),
    var(--ui-bg);
}

#overlay-root { position: relative; z-index: 50; }

/* ---------- navegação: trilho (paisagem) ---------- */
#nav {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  padding: calc(var(--safe-t) + var(--sp-5)) 0 calc(var(--safe-b) + var(--sp-5)) var(--safe-l);
  color: var(--sobre-escuro-apoio);
  background:
    radial-gradient(140% 50% at 50% 0%, color-mix(in srgb, var(--rose) 22%, transparent), transparent 65%),
    linear-gradient(180deg, var(--vinho) 0%, var(--vinho-profundo) 100%);
  box-shadow: inset -1px 0 0 color-mix(in srgb, var(--champanhe) 28%, transparent);
}

.nav-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  color: var(--rose);
}
.nav-brand svg { width: 40px; height: 53px; }
.nav-brand-word {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  color: var(--sobre-escuro);
  letter-spacing: .02em;
}

.nav-items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}

.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 72px;
  min-height: 76px;
  padding: var(--sp-2) 0;
  border-radius: 36px 36px 14px 14px;      /* o arco da marca */
  color: var(--sobre-escuro-apoio);
  transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease),
              transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.nav-item svg { width: 26px; height: 26px; }
.nav-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  line-height: 1;
}
.nav-item:active { transform: scale(.94); }
.nav-item.is-active {
  background: var(--perola);
  color: var(--vinho);
  box-shadow: 0 8px 22px color-mix(in srgb, black 30%, transparent),
              inset 0 0 0 1px color-mix(in srgb, var(--champanhe) 40%, transparent);
}
@media (hover: hover) {
  .nav-item:not(.is-active):hover { color: var(--sobre-escuro); background: color-mix(in srgb, var(--perola) 8%, transparent); }
}

/* ---------- navegação: barra inferior (retrato) ---------- */
@media (orientation: portrait) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    --nav-offset-b: calc(var(--nav-bar-h) + var(--safe-b));
    --view-safe-b: 0px;
  }
  #view { grid-column: 1; grid-row: 1; }
  #nav {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    justify-content: center;
    gap: 0;
    min-height: calc(var(--nav-bar-h) + var(--safe-b));
    padding: var(--sp-2) max(var(--sp-5), var(--safe-r)) calc(var(--safe-b) + var(--sp-2)) max(var(--sp-5), var(--safe-l));
    background:
      radial-gradient(60% 140% at 50% 0%, color-mix(in srgb, var(--rose) 18%, transparent), transparent 70%),
      linear-gradient(180deg, var(--vinho) 0%, var(--vinho-profundo) 100%);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--champanhe) 32%, transparent);
  }
  .nav-brand {
    position: absolute;
    left: max(var(--sp-6), var(--safe-l));
    top: 50%;
    transform: translateY(calc(-50% - var(--safe-b) / 2));
    flex-direction: row;
    gap: var(--sp-3);
  }
  .nav-brand svg { width: 28px; height: 37px; }
  .nav-brand-word { font-size: 20px; }
  .nav-items { flex-direction: row; gap: var(--sp-4); }
  .nav-item {
    width: 116px;
    min-height: 64px;
    border-radius: 32px 32px 12px 12px;
  }
}

/* telas sem navegação (atendimento, apresentação) */
#app[data-chrome="none"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  --nav-offset-b: 0px;
  --view-safe-b: var(--safe-b);
}
#app[data-chrome="none"] #nav { display: none; }
#app[data-chrome="none"] #view { grid-column: 1; grid-row: 1; }

/* ---------- entrada de tela (só opacidade: transform no #view quebraria position: fixed dos filhos) ---------- */
#view.view-enter { animation: glow-view-in var(--dur-2) var(--ease) both; }
#view.view-enter .screen-header { animation: glow-rise var(--dur-3) var(--ease-out) both; }
#view.view-enter .screen-body { animation: glow-rise var(--dur-3) var(--ease-out) 60ms both; }

@keyframes glow-view-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes glow-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes glow-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes glow-spin { to { transform: rotate(360deg); } }
@keyframes glow-breathe { 0%, 100% { opacity: .45; transform: scale(.97); } 50% { opacity: 1; transform: scale(1); } }

/* ---------- abertura (antes do JS) e carregamento de rota ---------- */
.boot, .route-loading {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  color: var(--vinho);
  padding: var(--sp-7);
}
.boot svg, .route-loading svg { width: 56px; height: 74px; color: var(--rose); animation: glow-breathe 1.8s var(--ease) infinite; }
.boot-word {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: var(--fs-2xl);
  line-height: 1;
  color: var(--vinho);
}
.route-loading { animation: glow-fade var(--dur-2) var(--ease) both; }

/* ---------- movimento reduzido: tudo vira fade ---------- */
@media (prefers-reduced-motion: reduce) {
  #view.view-enter .screen-header,
  #view.view-enter .screen-body { animation-name: glow-fade; }
  .boot svg, .route-loading svg { animation: none; }
  .nav-item:active { transform: none; }
}
