/* Screens. Uses the variables in tokens.css only (docs/design-guidelines.md, section 3.1). */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-grouped);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--text-body);
  line-height: 1.5;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

a { color: var(--color-accent); }

:focus-visible {
  outline: var(--focus-ring) solid var(--color-accent);
  outline-offset: var(--focus-gap);
}

[hidden] { display: none !important; }

/* Interface text isn't selected by accident; text people copy (phone numbers) is (section 10). */
.app-header, .card__actions, .install__actions, .actions, .link-row { -webkit-user-select: none; user-select: none; }
.selectable { -webkit-user-select: text; user-select: text; white-space: nowrap; }

/* One width for header, page and footer, so everything lines up on a computer. */
.app-header__inner, .layout {
  width: 100%;
  max-width: var(--width-page);
  margin: 0 auto;
}

/* Header */
.app-header {
  padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--margin-side) var(--space-3);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.app-header__inner { display: flex; align-items: center; gap: var(--space-2); }
.app-header__logo { width: 2.5rem; height: 2.5rem; margin: calc(-1 * var(--space-2)) 0; }
.app-header__name { font-size: var(--text-headline); font-weight: var(--weight-semibold); }

/* Page: a grid of cards. One column on phones; side by side from tablets up (section 7). */
.page { flex: 1; padding: var(--space-4) var(--margin-side) var(--space-6); }

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

/* Card */
.card {
  margin: 0;
  padding: var(--space-5);
  background: var(--color-bg);
  border-radius: var(--radius-surface);
  box-shadow: var(--shadow-card);
}
.card__head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.card__title {
  margin: 0;
  font-size: var(--text-headline);
  line-height: 1.35;
  font-weight: var(--weight-semibold);
}
.card__text { margin: var(--space-1) 0 0; color: var(--color-text-secondary); }
.card__head + .card__text { margin-top: 0; }
.card__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* Icon in a tinted square (section 7, small card with icon) */
.icon-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--size-icon-tile);
  height: var(--size-icon-tile);
  border-radius: var(--radius-control);
  background: var(--color-accent-tint);
  color: var(--color-accent);
}
.icon-tile svg, .pill__icon, .button__icon {
  width: var(--size-icon);
  height: var(--size-icon);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hero card: the one accent-filled card at the top (section 7) */
.hero {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.hero__body { flex: 1; min-width: 0; }
.hero__title {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-display);
  line-height: 1.15;
  font-weight: var(--weight-semibold);
}
.hero__text { margin: 0; max-width: 28rem; }
.hero__sun { flex: none; width: 4.5rem; height: auto; margin: calc(-1 * var(--space-3)) calc(-1 * var(--space-2)) 0 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-surface);
  background: var(--color-accent-tint);
  color: var(--color-accent);
  font-size: var(--text-small);
  font-weight: var(--weight-semibold);
}
.pill__icon { width: 1rem; height: 1rem; }

/* Contact card */
.contact__number {
  margin: var(--space-4) 0 0;
  font-size: var(--text-title-2);
  line-height: 1.25;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

/* Coming with sign-in: small cards with icons. Two across on phones, four on computers,
   one across when text is enlarged, because the minimum width is in rem. */
.section-title {
  margin: var(--space-3) 0 var(--space-3);
  font-size: var(--text-title-2);
  line-height: 1.25;
  font-weight: var(--weight-semibold);
}
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.card--small { padding: var(--space-4); }
.card--small .icon-tile { margin-bottom: var(--space-3); }
.card--small .card__text { font-size: var(--text-small); line-height: 1.45; }

/* Install offer (section 10): a quiet card in the page, never a pop-up */
.install { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.install__body { flex: 1 1 16rem; }
.install__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.install__actions .button { min-height: var(--size-touch); }

/* Buttons (section 5.1) */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--size-main-button);
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-control);
  font: inherit;
  font-weight: var(--weight-semibold);
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--easing);
}
.button:active { opacity: 0.7; }
.button--primary { background: var(--color-accent); color: var(--color-on-accent); }
.button--secondary { background: var(--color-accent-tint); color: var(--color-accent); }
.button--plain { background: transparent; color: var(--color-accent); padding: 0 var(--space-3); }

@media (hover: hover) {
  .button--primary:hover, .button--secondary:hover { filter: brightness(1.08); }
  .button--plain:hover { text-decoration: underline; }
}

/* Tablets and computers: hero and contact side by side, the rest full width */
@media (min-width: 48rem) {
  .page { padding-top: var(--space-6); padding-bottom: var(--space-7); }
  .layout { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--space-5); }
  .coming, .install { grid-column: 1 / -1; }
  .features { gap: var(--space-4); }
  .hero { padding: var(--space-6); align-items: center; }
  .hero__sun { width: 6rem; margin: 0; }
  .contact { display: flex; flex-direction: column; }
  .contact .card__actions { margin-top: auto; padding-top: var(--space-5); }
}

@media (min-width: 64rem) {
  .hero__sun { width: 8rem; }
}

/* Narrow phones (or large text): the sun steps aside so the words fit (it's also in the header),
   and the small cards turn into rows with the icon on the left. */
@media (max-width: 23.99rem) {
  .hero__sun { display: none; }
  .card--small {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--space-3);
    align-items: start;
  }
  .card--small .icon-tile { grid-row: span 2; margin-bottom: 0; }
}

/* ---- Sign-in screens (app/People): one task per card, one column, reading width ---- */

.layout--single { max-width: var(--width-reading); }

.page__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-title-1);
  line-height: 1.2;
  font-weight: var(--weight-semibold);
}
.page__lead { margin: 0 0 var(--space-5); color: var(--color-text-secondary); }
.page__detail { margin: var(--space-3) 0 0; font-size: var(--text-small); color: var(--color-text-secondary); }

/* A short note inside a card ("You're signed out"); warnings add the warning colour and words. */
.notice {
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-grouped);
  border-radius: var(--radius-control);
}
.notice p { margin: 0; }

.actions { display: flex; flex-direction: column; gap: var(--space-3); }
.actions form { margin: 0; }

/* Skip link: first thing a keyboard reaches; visible only when focused (WCAG 2.4.1). */
.skip-link {
  position: absolute;
  left: var(--margin-side);
  top: calc(-1 * var(--size-touch) - var(--space-4));
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border-radius: var(--radius-control);
}
.skip-link:focus { top: var(--space-2); }

/* Notices (section 7, Banner): a neutral note; warnings carry the warning colour as a side bar and words. */
.notice--warning { box-shadow: inset var(--space-1) 0 0 var(--color-warning); }

/* Forms (section 6): label above, hint under the label, error under the field. */
.form { margin: 0 0 var(--space-5); }
.field { margin: 0 0 var(--space-5); }
.field__label {
  display: block;
  margin: 0 0 var(--space-2);
  font-weight: var(--weight-semibold);
}
.field__hint {
  margin: calc(-1 * var(--space-1)) 0 var(--space-2);
  font-size: var(--text-small);
  color: var(--color-text-secondary);
}
.field__input {
  display: block;
  width: 100%;
  min-height: var(--size-main-button);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-body); /* 16 px or more, so iPhone Safari doesn't zoom in */
}
.field__input--code {
  max-width: 14rem;
  font-size: var(--text-title-2);
  letter-spacing: var(--space-1);
  font-variant-numeric: tabular-nums;
}
.field__input[aria-invalid="true"] { border-color: var(--color-danger); border-width: 2px; }
.field__error {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  margin: var(--space-2) 0 0;
  color: var(--color-danger);
  font-size: var(--text-small);
}
.field__icon {
  width: var(--size-icon);
  height: var(--size-icon);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-top: 0.05em;
}
.page__detail--before-actions { margin: 0 0 var(--space-5); }

/* Busy button: says what it's waiting for; the screen stays usable (section 5.3). */
.button[aria-busy="true"] { cursor: progress; opacity: 0.7; }
.button--wide { width: 100%; }

/* A row of plain, low-weight actions under a form */
.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
  margin-left: calc(-1 * var(--space-3));
}
.link-row form { margin: 0; }
.link-row .button { min-height: var(--size-touch); }
.sign-out { margin: var(--space-5) 0 0; margin-left: calc(-1 * var(--space-3)); }
.link-row .sign-out { margin: 0; }

/* Office help: its own card under each sign-in step */
.help__title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-headline);
  line-height: 1.35;
  font-weight: var(--weight-semibold);
}
.help__text { margin: 0 0 var(--space-3); color: var(--color-text-secondary); }
.actions--quiet .button { min-height: var(--size-touch); }

/* Sections and list rows (section 7, List row) */
.section { margin: 0 0 var(--space-5); }
.section__title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-title-2);
  line-height: 1.25;
  font-weight: var(--weight-semibold);
}
.rows {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--color-bg-grouped);
  border-radius: var(--radius-surface);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.row + .row { border-top: 1px solid var(--color-border); }
.row__text { display: flex; flex-direction: column; min-width: 0; }
.row__title { font-size: var(--text-headline); font-weight: var(--weight-semibold); }
.row__detail { font-size: var(--text-small); color: var(--color-text-secondary); }
.row__action { margin: 0; }
.row .button { min-height: var(--size-touch); }

@media (min-width: 48rem) {
  .layout--single { grid-template-columns: minmax(0, 1fr); }
  .actions { flex-direction: row; flex-wrap: wrap; }
  .card--task { padding: var(--space-6); }
}

/* Footer */
.app-footer {
  padding: 0 var(--margin-side) calc(var(--space-4) + env(safe-area-inset-bottom));
  text-align: center;
  font-size: var(--text-small);
}
.app-footer a {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-touch);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
