/* Home page (página inicial), model A "Cartão de destaque". Phones first; wider screens below.
   Colors only through tokens. Every block keeps its size while the data is on its way, so
   nothing jumps (the entrance animation lands its logo on .hero__logo). */

.home {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: max(var(--space-4), env(safe-area-inset-top, 0px)) max(var(--space-4), env(safe-area-inset-right, 0px))
    max(var(--space-8), env(safe-area-inset-bottom, 0px)) max(var(--space-4), env(safe-area-inset-left, 0px));
}

/* ----- top: monogram, greeting, search, theme, sign out ----------------------------------- */

.home__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4) var(--space-3);
}

.home__hello {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
}

/* SF monogram, discreet, before the greeting; as tall as the greeting line. */
.home__mark {
  flex: none;
  height: 1.5rem;
  margin-top: 0.0625rem;
}

/* One line each, always: the height of the top never depends on the name. */
.greet {
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.125rem, 5.45vw, 1.3125rem); /* a little smaller on narrow phones, to fit */
  line-height: 1.2;
  letter-spacing: var(--tracking-tight);
}

.greet__hello,
.greet__date {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.greet__sep {
  display: none;
}

.greet__date {
  margin-top: 0.125rem;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-body);
  letter-spacing: 0;
  color: var(--color-ink-muted);
}

.home__session {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  grid-column: 2;
  grid-row: 1;
}

.search {
  position: relative;
  display: block;
  grid-column: 1 / -1;
  grid-row: 2;
}

.search > .icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-ink-subtle);
  pointer-events: none;
}

.search__input {
  width: 100%;
  height: 3.25rem;
  padding: 0 var(--space-4) 0 3rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--font-size-md); /* 16px: phones do not zoom in on focus */
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.search__input::placeholder {
  color: var(--color-ink-subtle);
  opacity: 1;
}

.search__input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 22%, transparent);
}

/* Discreet error line (could not load, could not sign out). */
.home__alert {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  min-height: 3.25rem;
  border-radius: var(--radius-md);
  background: var(--color-warning-soft);
  color: var(--color-danger);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.home__alert .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.home__retry {
  flex: none;
  margin-left: auto;
  color: var(--color-ink);
}

/* ----- main: card, "Precisa de você", apps (in this order on phones) ----------------------- */

.home__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.hero {
  order: 1;
}

.needs {
  order: 2;
}

.apps,
.home__empty {
  order: 3;
}

/* While searching on a phone the apps come first, right under the search. */
.home__main.is-searching .needs {
  order: 4;
}

/* ----- SeinovFlow card (dark in both schemes) ---------------------------------------------- */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--color-hero-border);
  border-radius: var(--radius-card);
  background: var(--color-hero-bg);
  color: var(--color-hero-ink);
}

.hero__brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Keeps the logo's place and size from the first paint: the entrance animation lands here. */
.hero__logo {
  width: min(100%, 15.5rem);
  aspect-ratio: 4072 / 494;
}

.hero__tag {
  color: var(--color-hero-ink-muted);
  font-size: var(--font-size-sm);
}

.hero__day {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-hero-border);
}

.hero__dayhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 1.25rem;
}

.hero .eyebrow,
.hero .cur {
  color: var(--color-hero-ink-subtle);
}

.hero .sample {
  border-color: var(--color-hero-border);
  color: var(--color-hero-ink-subtle);
}

.hero__rev {
  font-size: var(--font-size-display);
  overflow-wrap: anywhere; /* a huge amount breaks the line instead of leaving the card */
}

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

.hero__stats dt {
  color: var(--color-hero-ink-subtle);
  font-size: var(--font-size-caption);
}

.hero__stats dd {
  margin-top: 0.125rem;
  font-size: 1.5rem;
}

/* The one number in cyan. On the dark card it is the dark-scheme cyan in both schemes. */
.hero__roas {
  color: var(--color-hero-accent);
}

/* Neutral main button (light with dark text on the dark card). The whole card opens it. */
.hero__open {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 3rem;
  margin-top: auto;
  border-radius: var(--radius-md);
  background: var(--color-hero-action);
  color: var(--color-hero-action-ink);
  font-size: var(--font-size-body-lg);
  font-weight: 600;
  white-space: nowrap;
  transition: opacity var(--duration-fast) ease;
}

.hero__open::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.hero:hover .hero__open {
  opacity: 0.92;
}

.hero__open:focus-visible {
  outline-color: var(--color-hero-accent);
  outline-offset: 3px;
}

.hero__open .icon {
  width: 1.125rem;
  height: 1.125rem;
  stroke-width: 1.8;
}

/* ----- app cards --------------------------------------------------------------------------- */

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

.app {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  min-height: 9.375rem;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-ink);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast) ease;
}

a.app:hover {
  border-color: var(--color-ink-subtle);
}

.app__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: auto;
  padding-bottom: var(--space-4);
}

.app__icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-alt);
}

.app__ext {
  display: grid;
  place-items: center;
  height: 1.375rem;
  color: var(--color-ink-subtle);
}

.app__ext .icon {
  width: 1rem;
  height: 1rem;
}

.app__flag {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 var(--space-2);
  border-radius: 999px;
  background: var(--color-surface-alt);
  color: var(--color-ink-muted);
  font-size: var(--font-size-2xs);
  font-weight: 500;
  white-space: nowrap;
}

.app__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--font-size-md);
  line-height: 1.25;
  letter-spacing: var(--tracking-snug);
}

.app__desc {
  margin-top: 0.125rem;
  color: var(--color-ink-muted);
  font-size: var(--font-size-caption);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* "em breve": only the outline, so what already opens stands out from what does not yet. */
.app--soon,
.app--ghost {
  background: transparent;
  cursor: default;
}

/* On the light page the hairline alone is too faint: a veil of the sheet color helps. */
@supports (color: light-dark(currentColor, currentColor)) {
  .app--soon,
  .app--ghost {
    background: light-dark(color-mix(in srgb, var(--color-surface) 40%, transparent), transparent);
  }
}

.app--soon .app__icon {
  background: transparent;
  color: var(--color-ink-muted);
}

.app--soon .app__name {
  color: var(--color-ink-muted);
}

.app--soon .app__desc {
  color: var(--color-ink-subtle);
}

/* No app matches the search. */
.home__empty {
  padding: var(--space-8) var(--space-4);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-card);
  color: var(--color-ink-muted);
  text-align: center;
}

.home__empty:empty {
  display: none;
}

/* ----- "Precisa de você" ------------------------------------------------------------------- */

.needs__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 1.5rem;
  margin-bottom: var(--space-3);
}

.needs__title {
  flex: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: var(--tracking-tight);
}

.needs__meta {
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-ink-subtle);
  font-size: var(--font-size-caption);
}

.needs__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  overflow: hidden;
}

/* A hairline above and on the left of every item; the list clips the ones on its own edge, so
   the dividers are right for any number of items and columns. */
.need {
  display: grid;
  grid-template-columns: minmax(2.25rem, auto) minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-4);
  box-shadow: 0 -1px 0 var(--color-border), -1px 0 0 var(--color-border);
}

.need__lead {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--font-size-xl);
  line-height: 1;
  letter-spacing: var(--tracking-figure);
  text-align: center;
}

.need__lead--alert {
  display: grid;
  justify-items: center;
  align-content: start;
  color: var(--color-warning);
}

.need__lead--alert .icon {
  width: 1.75rem;
  height: 1.75rem;
}

.need__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.need__title {
  font-weight: 600;
  font-size: var(--font-size-body-lg);
  line-height: 1.3;
}

.need__when {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: var(--radius-sm);
  background: var(--color-warning-soft);
  color: var(--color-warning);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
}

.need__text {
  margin: 0.125rem 0 var(--space-3);
  color: var(--color-ink-muted);
  font-size: var(--font-size-caption);
  line-height: 1.4;
}

.need__go {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 2.25rem;
  margin-top: auto;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-alt);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--duration-fast) ease;
}

/* Touch area of 44px without making the button look bigger. */
.need__go::after {
  content: "";
  position: absolute;
  inset: -0.3125rem 0;
}

.need__go:hover {
  border-color: var(--color-ink-subtle);
}

.need__go .icon {
  width: 1rem;
  height: 1rem;
}

.need__go--ghost {
  width: 6.5rem;
  visibility: hidden;
}

.need--none {
  grid-template-columns: minmax(0, 1fr);
  padding: var(--space-6) var(--space-4);
  color: var(--color-ink-muted);
  font-size: var(--font-size-sm);
}

/* Narrow phones: with the "exemplo" mark there is no room for the word "atualizado". */
@media (max-width: 429px) {
  .needs__head .sample:not([hidden]) ~ .needs__meta .needs__word {
    display: none;
  }
}

/* ----- from tablets up: the top in one row, four apps per row ------------------------------- */

@media (min-width: 700px) {
  .home {
    padding: var(--space-6) var(--space-6) var(--space-8);
  }

  .home__top {
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 20rem) auto;
    gap: var(--space-4);
  }

  .search {
    grid-column: 2;
    grid-row: 1;
  }

  .home__session {
    grid-column: 3;
  }

  .search__input {
    height: 2.75rem;
  }

  .hero__stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .apps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .needs__list {
    grid-template-columns: repeat(var(--needs-columns, 3), minmax(0, 1fr));
  }
}

/* ----- computers: card on the left, apps on the right, "Precisa de você" below --------------- */

@media (min-width: 1200px) {
  .home {
    gap: var(--space-7);
    max-width: 90rem;
    margin: 0 auto;
    padding: var(--space-10) clamp(2rem, 3.9vw, 3.5rem);
  }

  .home__top {
    grid-template-columns: minmax(0, 1fr) 22.5rem auto;
  }

  .home__hello {
    align-items: center;
    gap: var(--space-4);
  }

  .home__mark {
    height: 1.75rem;
    margin-top: 0;
  }

  /* Greeting and date on the same line. */
  .greet {
    overflow: hidden;
    font-size: 1.625rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .greet__hello,
  .greet__date {
    display: inline;
    overflow: visible;
  }

  .greet__sep {
    display: inline;
  }

  .greet__sep,
  .greet__date {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: 400;
    font-size: var(--font-size-md);
    letter-spacing: 0;
    color: var(--color-ink-muted);
  }

  .greet__sep {
    color: var(--color-ink-subtle);
  }

  .search__input {
    font-size: var(--font-size-body-lg);
  }

  .home__main {
    display: grid;
    grid-template-columns: clamp(21rem, 28vw, 24.5rem) minmax(0, 1fr);
    gap: var(--space-7) var(--space-4);
  }

  .hero {
    grid-column: 1;
    grid-row: 1;
    padding: var(--space-7);
  }

  .hero__logo {
    width: min(100%, 17rem);
  }

  .hero__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* The rows are fixed by the number of apps, so the cards keep their size while searching. */
  .apps {
    grid-column: 2;
    grid-row: 1;
    grid-template-rows: repeat(var(--apps-rows, 2), 1fr);
    gap: var(--space-4);
  }

  .app {
    min-height: 9.75rem;
    padding: var(--space-5);
  }

  .home__empty {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .needs,
  .home__main.is-searching .needs {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  /* The card is filtered out by the search: the apps take the whole row. */
  .home__main--no-hero .apps {
    grid-column: 1 / -1;
    grid-template-rows: none;
  }

  .need {
    padding: var(--space-5) var(--space-6);
  }
}
