/* Layout and components. Design values come from tokens.css. */

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  /* Set from the chosen palette. Deliberately not transitioned: a transition on
     a property whose value comes from a custom property set on another element
     latches onto the old computed colour and never lands on the new one, which
     left the background stuck on the previous colour. */
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  /* dvh keeps the layout stable while mobile browser chrome collapses. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(var(--space-5) + env(safe-area-inset-top))
    calc(var(--space-5) + env(safe-area-inset-right))
    calc(var(--space-6) + env(safe-area-inset-bottom))
    calc(var(--space-5) + env(safe-area-inset-left));
}

/* ---------- Start view ---------- */

.start {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-6);
}

.start__header {
  padding-top: var(--space-6);
}

/* One file for every palette. The SVG is used as a mask, so only its alpha
   matters; the colour comes from background-color and therefore follows the
   palette's text colour — dark on coral and green, light on cobalt. A light
   and a dark variant would need a third rule deciding which applies when.
   aspect-ratio matches the artwork's viewBox so nothing is squashed. */
.mark {
  width: 4.5rem;
  aspect-ratio: 1027.6 / 851;
  margin-bottom: var(--space-4);
  background-color: var(--color-text);
  -webkit-mask: url("../assets/icons/mark.svg") center / contain no-repeat;
  mask: url("../assets/icons/mark.svg") center / contain no-repeat;
}

.start__title {
  margin: 0;
  font-size: clamp(2.5rem, 10vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.start__intro {
  margin: var(--space-2) 0 0;
  color: var(--color-text-dim);
}

.start__packs {
  display: flex;
  flex-direction: column;
  margin-top: auto;
}

.pack {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) 0;
  border-top: 1px solid var(--color-line);
  color: inherit;
  text-decoration: none;
}

.start__packs .pack:last-child {
  border-bottom: 1px solid var(--color-line);
}

.pack:hover .pack__title,
.pack:focus-visible .pack__title {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.pack:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

.pack__body {
  display: flex;
  flex-direction: column;
}

.pack__title {
  font-size: 1.625rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.pack__subtitle {
  color: var(--color-text-dim);
  font-size: var(--text-meta);
}

/* ---------- Participants view ---------- */

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

.participants__header {
  padding-top: var(--space-5);
}

.participants__title {
  margin: 0;
  font-size: clamp(2.125rem, 8.5vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.participants__intro {
  margin: var(--space-2) 0 0;
  color: var(--color-text-dim);
  font-size: var(--text-meta);
}

.fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.field__input {
  flex: 1;
  min-width: 0;
  padding: var(--space-3) 0;
  border: 0;
  border-bottom: 1px solid var(--color-line);
  border-radius: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 1.4375rem;
  letter-spacing: -0.01em;
}

.field__input::placeholder {
  color: var(--color-text-dim);
  opacity: 0.65;
}

.field__input:focus {
  outline: none;
  border-bottom-color: var(--color-text);
}

.field__remove {
  appearance: none;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text-dim);
  font: inherit;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.field__remove:hover,
.field__remove:focus-visible {
  color: var(--color-text);
}

.field__remove:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -6px;
  border-radius: 50%;
}

.textbutton {
  align-self: flex-start;
  appearance: none;
  padding: var(--space-2) 0;
  border: 0;
  background: transparent;
  color: var(--color-text-dim);
  font: inherit;
  font-size: var(--text-meta);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.textbutton:hover,
.textbutton:focus-visible {
  color: var(--color-text);
}

.participants__note {
  margin: 0;
  color: var(--color-text-dim);
  font-size: var(--text-meta);
  text-align: center;
}

/* ---------- Session view ---------- */

.session {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
}

.iconbutton {
  appearance: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-left: calc(var(--space-3) * -1);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text-dim);
  font: inherit;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.iconbutton:hover,
.iconbutton:focus-visible {
  color: var(--color-text);
}

.iconbutton:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -4px;
  border-radius: 50%;
}

/* The card is defined by space, not by a border or a shadow. */
.card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6) 0;
  transition:
    opacity var(--transition-card),
    transform var(--transition-card);
}

.card[data-state="leaving"] {
  opacity: 0;
  transform: translateY(8px);
}

.card[data-state="entering"] {
  opacity: 0;
  transform: translateY(-8px);
}

/* Two lines sit above the question, and they are not equals. The turn is an
   instruction and has to be read; the theme is context and may be skipped.
   Same size and colour made them a single grey blur, so they are separated by
   weight and strength instead of by space. */
.card__meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.card__turn {
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-meta);
  font-weight: 500;
}

.card__theme {
  margin: 0;
  color: var(--color-text-dim);
  font-size: var(--text-meta);
  font-weight: 400;
  letter-spacing: 0.06em;
}

.card__question {
  margin: 0;
  max-width: var(--measure-question);
  font-size: var(--text-question);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.card__note {
  margin: 0;
  max-width: var(--measure-question);
  color: var(--color-text-dim);
  font-size: var(--text-body);
}

/* The offer sits apart from the practical note above it, so it reads as an
   invitation rather than another instruction. */
.card__note + .card__note {
  margin-top: var(--space-4);
}

/* ---------- Interest signup ---------- */

.signup {
  margin-top: var(--space-3);
  max-width: var(--measure-question);
}

.signup__form {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

.signup__input {
  flex: 1;
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-body);
}

.signup__input::placeholder {
  color: var(--color-text-dim);
  opacity: 0.7;
}

.signup__input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-color: transparent;
}

.signup__input:disabled {
  opacity: 0.5;
}

.signup__submit {
  appearance: none;
  flex: none;
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.signup__submit:hover:not(:disabled),
.signup__submit:focus-visible {
  background: rgba(var(--color-text-rgb), 0.08);
  border-color: rgba(var(--color-text-rgb), 0.55);
}

.signup__submit:disabled {
  opacity: 0.5;
  cursor: default;
}

.signup__status:empty {
  display: none;
}

.signup__status {
  margin: var(--space-3) 0 0;
  font-size: var(--text-meta);
  color: var(--color-text-dim);
}

.signup__status[data-kind="done"] {
  color: var(--color-text);
  font-weight: 500;
}

.signup__note {
  margin: var(--space-2) 0 0;
  color: var(--color-text-dim);
  font-size: var(--text-meta);
  opacity: 0.85;
}

/* ---------- Actions ---------- */

.actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
}

/* Button plus the note underneath it, on the participants screen. */
.actions--stacked {
  flex-direction: column;
  align-items: center;
  margin-top: auto;
}

.button:disabled {
  opacity: 0.4;
  cursor: default;
}

.button:disabled:hover {
  background: transparent;
  border-color: var(--color-line);
}

.button {
  appearance: none;
  min-width: 11rem;
  padding: var(--space-4) var(--space-6);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.button:hover,
.button:focus-visible {
  background: rgba(var(--color-text-rgb), 0.08);
  border-color: rgba(var(--color-text-rgb), 0.55);
}

.button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.button:active {
  background: rgba(var(--color-text-rgb), 0.14);
}

/* ---------- Sheet menu ---------- */

/* <dialog> brings the focus trap, Escape-to-close and page inertness for free.
   Positioned as a full-screen box so a click on the element itself counts as a
   click on the backdrop. */
.sheet {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  max-height: none;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.sheet__items {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding:
    var(--space-3)
    calc(var(--space-4) + env(safe-area-inset-right))
    calc(var(--space-4) + env(safe-area-inset-bottom))
    calc(var(--space-4) + env(safe-area-inset-left));
  background: var(--color-bg);
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
  animation: sheet-rise 240ms cubic-bezier(0.32, 0.72, 0.28, 1);
}

@keyframes sheet-rise {
  from { transform: translateY(1.5rem); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet__items { animation: none; }
}

.sheet__item {
  appearance: none;
  width: 100%;
  padding: var(--space-4) var(--space-2);
  border: 0;
  border-bottom: 1px solid var(--color-line);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 1.1875rem;
  text-align: left;
  cursor: pointer;
}

.sheet__item:last-child {
  border-bottom: 0;
}

.sheet__item:hover,
.sheet__item:focus-visible {
  background: rgba(var(--color-text-rgb), 0.08);
}

.sheet__item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.sheet__item--quiet {
  color: var(--color-text-dim);
}

.sheet__item--destructive {
  font-weight: 600;
}

.sheet__confirm {
  padding: var(--space-4) var(--space-2) var(--space-5);
}

.sheet__title {
  margin: 0;
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sheet__note {
  margin: var(--space-2) 0 0;
  color: var(--color-text-dim);
  font-size: var(--text-meta);
}

/* ---------- About view ---------- */

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

.about__title {
  margin: var(--space-4) 0 0;
  font-size: clamp(2.125rem, 8.5vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.about__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: var(--measure-question);
}

.about__line {
  margin: 0;
  color: var(--color-text-dim);
}

.about__section {
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-line);
}

.about__heading {
  margin: 0 0 var(--space-3);
  font-size: var(--text-meta);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--color-text-dim);
}

.about__note {
  margin: var(--space-2) 0 0;
  color: var(--color-text-dim);
  font-size: var(--text-meta);
  max-width: var(--measure-question);
}

.about__note + .about__note {
  margin-top: var(--space-4);
}

.about__footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: auto 0 0;
}

.about__credit,
.about__version {
  margin: 0;
  color: var(--color-text-dim);
  font-size: var(--text-meta);
}

.start__about {
  margin-bottom: var(--space-4);
  color: var(--color-text-dim);
  font-size: var(--text-meta);
  text-underline-offset: 0.25em;
}

.start__about:hover,
.start__about:focus-visible {
  color: var(--color-text);
}

.swatches {
  display: flex;
  gap: var(--space-3);
}

.swatch {
  appearance: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  /* A ring in the text colour, held off the swatch so the colour reads clean. */
  box-shadow: 0 0 0 1px rgba(var(--color-text-rgb), 0.25);
}

.swatch.is-active {
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-text);
}

.swatch:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 4px;
}

/* The tick is drawn in the palette's own text colour, so it stays legible on
   whichever swatch it lands on. */
.swatch__mark {
  width: 0.75rem;
  height: 0.4rem;
  border-left: 2px solid;
  border-bottom: 2px solid;
  transform: rotate(-45deg) translate(1px, -2px);
  opacity: 0;
}

.swatch.is-active .swatch__mark {
  opacity: 1;
}

.toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.toggle__input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--color-text);
  cursor: pointer;
}

.textbutton--destructive {
  color: var(--color-text);
}

/* ---------- Failure state ---------- */

.error {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: auto;
  max-width: var(--measure-question);
  color: var(--color-text-dim);
  text-align: center;
}

.textlink {
  color: var(--color-text);
  text-underline-offset: 0.2em;
}
