/* ============================================================================
   home.css — tela de início
   O caminho comum na frente: criar. O histórico logo abaixo, na ordem em que
   a pessoa mexeu pela última vez.
   ========================================================================= */

.home {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  background: var(--bg);
}
/* visibility junto com display: garante que o compositor descarte a camada,
   e não só pare de reservar espaço para ela */
body.is-home    .home   { display: flex; visibility: visible; }
body.is-home    .editor { display: none; }
body:not(.is-home) .home { display: none; visibility: hidden; }

/* Sem backdrop-filter aqui de propósito. O fundo da tela de início é branco
   liso: um vidro fosco sobre branco liso é indistinguível de branco liso — só
   cria uma camada composta a mais. E camada composta em elemento fixo que
   entra e sai do display deixa resíduo de pintura no Chrome. */
.home__bar-end {
  display: flex; align-items: center; gap: var(--gap-2);
}

.home__bar {
  flex: 0 0 auto;
  height: var(--toolbar-h);
  padding: 0 var(--gap-4);
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; justify-content: space-between; gap: var(--gap-3);
  background: var(--bg);
  box-shadow: 0 1px 0 var(--separator);
}
.home__storage {
  font-size: .6875rem; color: var(--label-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.home__scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* Largura cheia no desktop. Uma coluna estreita no meio de um MacBook deixa
   dois terços da tela vazios; com a largura toda, as últimas edições viram uma
   grade e cabem muito mais na primeira olhada. */
.home__inner {
  width: 100%;
  padding: var(--gap-5) var(--gap-5) calc(var(--gap-6) + env(safe-area-inset-bottom));
}

/* ─────────────  O BLOCO DO +  ───────────── */
.newtile {
  width: 100%;
  min-height: 172px;
  padding: var(--gap-5) var(--gap-4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--gap-2);
  border-radius: var(--r-xl);
  border: 2px dashed var(--separator-firm);
  background: var(--bg-elevated);
  color: var(--label);
  transition: transform 110ms ease-out, border-color 180ms ease-out,
              background-color 180ms ease-out;
}
.newtile:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.newtile:active { transform: scale(.985); }

.newtile__plus {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms cubic-bezier(.32,.72,0,1);
}
.newtile__plus svg { width: 26px; height: 26px; stroke-width: 2; }
.newtile:hover .newtile__plus { transform: scale(1.06); }

.newtile__label {
  font-size: 1.0625rem; line-height: 1.25; letter-spacing: -.012em;
  font-weight: var(--w-medium);
}
.newtile__hint {
  font-size: .75rem; line-height: 1.4; letter-spacing: -.002em;
  color: var(--label-2); text-align: center;
}

/* ─────────────  ÚLTIMAS EDIÇÕES  ───────────── */
.recents { margin-top: var(--gap-6); }

.recents__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--gap-2);
  padding: 0 var(--gap-1) var(--gap-2);
}
.recents__title {
  margin: 0;
  font-size: .8125rem; font-weight: var(--w-medium); letter-spacing: -.004em;
}
.recents__count { font-size: .6875rem; color: var(--label-3); }

/* ─────────────  busca  ─────────────
   Só aparece quando há projetos o bastante pra justificar procurar. */
.search {
  position: relative;
  display: flex; align-items: center;
  margin: 0 0 var(--gap-3);
}
.search__icon {
  position: absolute; left: 13px;
  width: 17px; height: 17px;
  color: var(--label-3);
  pointer-events: none;
}
.search__input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 38px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--fill);
  color: var(--label);
  /* 16px: abaixo disso o iOS dá zoom sozinho ao focar o campo */
  font-size: 1rem;
  letter-spacing: -.006em;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 150ms ease-out;
}
.search__input::placeholder { color: var(--label-3); }
.search__input::-webkit-search-cancel-button { display: none; }
.search__input:hover { background: var(--fill-strong); }
/* Sem anel de foco no clique: o fundo mais claro já mostra onde está o cursor. */
.search__input:focus { outline: none; background: var(--fill-strong); }
.search__input:focus-visible { outline: none; }

.search__clear {
  position: absolute; right: 6px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--label-3);
  transition: color 150ms ease-out, background-color 150ms ease-out;
}
.search__clear svg { width: 13px; height: 13px; stroke-width: 1.8; }
.search__clear:hover { color: var(--label); background: var(--fill-strong); }

.recents__list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--gap-2);
}

.recents__empty {
  padding: var(--gap-5) 0;
  text-align: center;
  font-size: .8125rem; color: var(--label-3);
}

.project {
  position: relative;
  display: flex; align-items: center; gap: var(--gap-3);
  width: 100%;
  padding: var(--gap-2);
  border: 1px solid var(--separator);   /* contorno bem fraco: separa sem pesar */
  border-radius: var(--r-lg);
  background: var(--bg);
  text-align: left;
  transition: transform 110ms ease-out, background-color 160ms ease-out,
              border-color 160ms ease-out;
}
.project:hover { background: var(--bg-elevated); border-color: var(--separator-firm); }
.project:active { transform: scale(.99); background: var(--fill); }

.project__thumb {
  flex: 0 0 auto;
  width: 54px; height: 54px;
  border-radius: var(--r-md);
  object-fit: cover; display: block;
  background: var(--fill);
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.1);
}
.project__thumb--empty {
  display: grid; place-items: center;
  color: var(--label-3);
}
.project__thumb--empty svg { width: 22px; height: 22px; }

.project__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.project__name {
  display: block;
  font-size: .875rem; line-height: 1.3; letter-spacing: -.008em;
  font-weight: var(--w-medium);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project__meta {
  display: block;
  margin-top: 2px;
  font-size: .6875rem; line-height: 1.35; color: var(--label-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.project__go { flex: 0 0 auto; width: 16px; height: 16px; color: var(--label-3); }

.project__delete {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--label-3);
  opacity: 0;
  transition: opacity 150ms ease-out, background-color 150ms ease-out, color 150ms ease-out;
}
.project__delete svg { width: 15px; height: 15px; }
.project:hover .project__delete { opacity: 1; }
.project__delete:hover { background: var(--fill-strong); color: var(--danger); }
.project__delete:focus-visible { opacity: 1; }
@media (hover: none) {
  .project__delete { opacity: 1; }
}

/* ─────────────  margens laterais no desktop  ─────────────
   A barra do topo e o conteúdo respiram no mesmo eixo: se só o conteúdo
   recuasse, a logo ficaria pendurada fora do alinhamento de tudo embaixo. */
@media (min-width: 760px) {
  .home__bar,
  .home__inner { padding-left: var(--gap-6); padding-right: var(--gap-6); }
  .newtile { min-height: 148px; }
  .recents__list {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--gap-2);
  }
  .search { max-width: 420px; }
}
@media (min-width: 1120px) {
  .home__bar,
  .home__inner { padding-left: 120px; padding-right: 120px; }
}

@media (min-width: 1440px) {
  .home__bar,
  .home__inner { padding-left: 320px; padding-right: 320px; }
  .recents__list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

.home__empty {
  margin: var(--gap-6) 0 0;
  text-align: center;
  font-size: .8125rem; color: var(--label-3);
}

/* ─────────────  CAMPO DE TEXTO  ───────────── */
.input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--separator-firm);
  border-radius: var(--r-md);
  background: #fff;
  font-size: 1rem;               /* 16px evita o zoom automático do iOS */
  letter-spacing: -.006em;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
/* Sem anel de foco no clique — o campo já muda de fundo. Quem navega por
   teclado continua vendo um contorno claro (:focus-visible logo abaixo):
   remover a indicação pra todo mundo deixaria a navegação por Tab cega. */
.input:focus {
  outline: none;
  border-color: var(--separator-firm);
  background: var(--bg-elevated);
}
/* Idem: o Chrome casa :focus-visible em campo de texto até no clique, então
   um outline aqui viraria "borda que aparece do nada" ao escrever. */
.input:focus-visible {
  outline: none;
  border-color: var(--separator-firm);
}
.input::placeholder { color: var(--label-3); }

/* ============================================================================
   Etapa de escolha da foto — entre nomear o projeto e abrir o editor.
   A foto entra antes: assim o editor abre já com o que editar, sem tela vazia
   e sem uma coluna de miniaturas ocupando espaco que a foto quer usar.
   ========================================================================= */
.picker {
  position: fixed; inset: 0; z-index: 12;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
body.is-picker     .picker { display: flex; visibility: visible; }
body:not(.is-picker) .picker { display: none; visibility: hidden; }
body.is-picker .home   { display: none; visibility: hidden; }
body.is-picker .editor { display: none; }

.picker .home__bar-end {
  display: flex; align-items: center; gap: var(--gap-2);
}

.home__bar { justify-content: space-between; }

.picker__body {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--gap-3);
  padding: var(--gap-6) var(--gap-4) calc(var(--gap-6) + env(safe-area-inset-bottom));
  text-align: center;
  transition: background-color 180ms ease-out;
}
.picker__body.is-dragover { background: var(--accent-tint); }
.picker__body.is-dragover .picker__art { color: var(--accent); }

.picker__art { width: 78px; height: 78px; color: var(--label-3); }
.picker__art svg { width: 100%; height: 100%; stroke-width: 2; }

.picker__title {
  margin: 0;
  font-size: 1.5rem; line-height: 1.15; letter-spacing: -.02em;
  font-weight: var(--w-medium);
}
.picker__sub {
  margin: 0; max-width: 36ch;
  font-size: .8125rem; line-height: 1.5; color: var(--label-2);
}
.picker__hint {
  margin: 0; font-size: .75rem; color: var(--label-3);
}
@media (hover: none) { .picker__hint { display: none; } }
