/*
 * The Belle Ame app. Every colour and size comes from tokens.css.
 * Rules: dev/kit/30-design-system/ — tile.md, launcher-layout.md, notices.md, about-page.md.
 */

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

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

body {
  min-height: 100dvh;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  background: var(--app-page);
  color: var(--app-text);
  font-family: var(--app-font-body);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--app-accent-deep);
  outline-offset: 2px;
}

/* ---------- Header (launcher-layout.md) ---------- */

.app-head {
  padding: 1.375rem var(--app-gap) 0.25rem;
  text-align: center;
}

.app-head__title {
  margin: 0;
  font-weight: inherit;
}

.app-head__kicker {
  display: block;
  padding-inline-start: 0.3em; /* balances the trailing letter-spacing so it centres */
  color: var(--app-text-muted);
  font-family: var(--app-font-body);
  font-size: var(--app-size-kicker);
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.app-head__name {
  display: block;
  margin-top: 0.3125rem;
  font-family: var(--app-font-display);
  font-size: var(--app-size-title);
  font-weight: 500;
  line-height: 1.15;
  text-wrap: balance;
}

.app-head__rule {
  width: 2.125rem;
  height: 1px;
  margin: 0.6875rem auto 0;
  background: var(--app-accent);
}

/* ---------- Install line (notices.md) — browser only, unhidden by app.js ---------- */

.install-line {
  margin: 0;
  padding: 0.75rem 0.5rem;
  border: 0;
  background: none;
  color: var(--app-text-muted);
  cursor: pointer;
  font: 500 var(--app-size-small) / 1.2 var(--app-font-body);
  text-decoration: underline 1px var(--app-accent);
  text-underline-offset: 3px;
}

/* ---------- Grid (launcher-layout.md) ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(var(--app-tile-min), calc((100% - var(--app-gap)) / 2)), 1fr)
  );
  gap: var(--app-gap);
  margin: 0;
  padding: var(--app-gap);
  list-style: none;
}

.tile-grid > li {
  display: flex;
}

/* ---------- Tile (tile.md) — museum plate, arched picture ---------- */

.tile {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: var(--app-mat);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: inset 0 0 0 1px var(--app-line);
  color: var(--app-text);
  text-decoration: none;
  -webkit-tap-highlight-color: var(--app-clear);
  transition: transform 0.12s ease;
}

.tile:active {
  transform: scale(0.985);
}

.tile__art {
  display: block;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  border-radius: var(--app-arch);
  background: var(--app-line);
  box-shadow: 0 0 0 1px var(--app-line-strong);
}

.tile__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile__name {
  display: block;
  padding: 0.65em 0.2em 0.1em;
  font-size: var(--app-size-tile);
  font-weight: 500;
  letter-spacing: 0.11em;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
}

/* ---------- Footer link (launcher-layout.md) ---------- */

.app-foot {
  padding: 1rem var(--app-gap) 1.5rem;
  text-align: center;
}

.app-foot a {
  display: inline-block;
  padding: 0.75rem 0.5rem;
  color: var(--app-text-muted);
  font-size: var(--app-size-small);
  font-weight: 500;
  text-underline-offset: 3px;
}

/* ---------- Install panel (notices.md) ---------- */

.sheet {
  width: 100%;
  max-width: min(30rem, 100%);
  max-height: 100%;
  margin: auto auto 0;
  padding: 1.375rem 1.375rem calc(1.375rem + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 1rem 1rem 0 0;
  background: var(--app-surface);
  box-shadow: 0 -0.5rem 1.5rem var(--app-shadow);
  color: var(--app-text);
}

.sheet::backdrop {
  background: var(--app-scrim);
}

.sheet[open] {
  animation: sheet-rise 0.2s ease-out;
}

@keyframes sheet-rise {
  from {
    transform: translateY(100%);
  }
}

/* The panel opens with focus on its title (read out first, no ring on a button). */
.sheet__title:focus {
  outline: none;
}

.sheet__title {
  margin: 0 0 0.75rem;
  font-family: var(--app-font-display);
  font-size: var(--app-size-h1);
  font-weight: 500;
  line-height: 1.25;
}

.sheet__steps,
.sheet__lead {
  margin: 0;
  font-size: var(--app-size-body);
  line-height: 1.5;
}

.sheet__steps {
  padding-inline-start: 1.25rem;
}

.sheet__steps li + li {
  margin-top: 0.375rem;
}

.sheet__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.375rem;
}

.button {
  min-height: 2.75rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: var(--app-radius);
  cursor: pointer;
  font: 500 var(--app-size-body) / 1 var(--app-font-body);
}

.button--primary {
  background: var(--app-accent-deep);
  color: var(--app-on-accent);
}

.button--text {
  background: none;
  color: var(--app-text);
}

/* ---------- Offline notice (notices.md) ---------- */

.notice {
  position: fixed;
  z-index: 10;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  left: 50%;
  width: max-content;
  max-width: min(22.5rem, calc(100% - 2rem));
  padding: 0.75rem 1rem;
  border-radius: var(--app-radius);
  background: var(--app-text);
  color: var(--app-page);
  font-size: var(--app-size-notice);
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.15s ease;
}

.notice.is-visible {
  opacity: 1;
}

/* ---------- About page (about-page.md) ---------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0 var(--app-gap);
  color: var(--app-text);
  font-size: var(--app-size-notice);
  text-decoration: none;
}

.about {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 1.375rem 2.5rem;
  font-size: var(--app-size-body);
  line-height: 1.6;
}

.about h1 {
  margin: 1.75rem 0 0;
  font-family: var(--app-font-display);
  font-size: var(--app-size-h1);
  font-weight: 500;
  text-align: center;
}

.about h2 {
  margin: 2rem 0 0.625rem;
  font-family: var(--app-font-display);
  font-size: var(--app-size-h2);
  font-weight: 500;
  line-height: 1.3;
}

.about p {
  margin: 0 0 0.75rem;
}

.about a {
  text-decoration-color: var(--app-accent);
  text-underline-offset: 3px;
}

.credits {
  display: grid;
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.credit {
  display: grid;
  grid-template-columns: 4rem 1fr;
  align-items: start;
  gap: 0.875rem;
}

.credit__thumb {
  display: block;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  border-radius: 48% 48% 0.25rem 0.25rem / 30% 30% 0.25rem 0.25rem;
  box-shadow: 0 0 0 1px var(--app-line-strong);
}

.credit__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.credit__tile {
  display: block;
  color: var(--app-text-muted);
  font-size: var(--app-size-tile);
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.credit__title {
  display: block;
  font-style: italic;
}

.credit__meta,
.credit__pending {
  display: block;
  color: var(--app-text-muted);
  font-size: var(--app-size-notice);
  line-height: 1.45;
}

.credit__pending {
  font-style: italic;
}

.about-foot {
  margin-top: 2.5rem;
  color: var(--app-text-muted);
  font-size: var(--app-size-small);
  text-align: center;
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .tile,
  .notice {
    transition: none;
  }

  .sheet[open] {
    animation: none;
  }
}
