/*
 * The HTML join pages (docs/ux/web-join.md, docs/web-join-architecture.md §3).
 *
 * docs/02's tokens, spelled as custom properties. They are the app's
 * PalmColors, PalmSpacing and PalmRadii (lib/core/theme/tokens.dart), and a
 * test holds them equal (test/tool/make_pages_test.dart), because two copies of
 * a colour drift the day somebody tunes one.
 *
 * Type is in rem, so that the browser's own text size reaches it: the relative
 * who turned their text up gets the form at their size, and nothing here
 * measures text in pixels that would clip it. No inline style anywhere: the
 * page's policy allows none (tool/web/serve.dart).
 */

:root {
  --night: #0D1526;
  --night-2: #152038;
  --border: #243356;
  --gold: #E9B949;
  --coral: #FF6A5B;
  --cream: #F7EFE0;
  --slate: #8B94AB;

  --xs: 4px;
  --sm: 8px;
  --md: 16px;
  --lg: 24px;
  --xl: 32px;
  --xxl: 48px;
  --tap: 48px;

  --r-hero: 28px;
  --r-control: 20px;
  --r-pill: 999px;

  color-scheme: dark;
}

@font-face {
  font-family: "Tajawal";
  font-weight: 400;
  font-display: swap;
  src: url("fonts/page/tajawal-400.woff2") format("woff2");
}

@font-face {
  font-family: "Tajawal";
  font-weight: 700;
  font-display: swap;
  src: url("fonts/page/tajawal-700.woff2") format("woff2");
}

/* The app's name and the room code only: the cut has nothing else in it. */
@font-face {
  font-family: "Lalezar";
  font-weight: 400;
  font-display: swap;
  src: url("fonts/page/lalezar-400.woff2") format("woff2");
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--night);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--night);
  color: var(--cream);
  font-family: "Tajawal", system-ui, sans-serif;
  font-size: 1.125rem;
  line-height: 1.5;
}

/* The game draws over the page once it runs: the form goes out of the way. */
html.playing .banner,
html.playing .page {
  display: none !important;
}

/*
 * The game's own elements, left to right. The page is right to left
 * (<html dir="rtl">), and Flutter puts its view in the body, so its
 * semantics nodes inherited it: absolutely placed with a transform and no
 * left, a node then started from its parent's right edge, and every one
 * narrower than its parent sat off to one side by the difference. The back
 * arrow's was at x = 632 on a 360-wide phone, where a screen reader's
 * explore-by-touch never finds it. Flutter lays out right to left itself;
 * the DOM it writes must not do it again.
 */
flutter-view,
flt-semantics-host {
  direction: ltr;
}

.page {
  max-width: 30rem;
  margin: 0 auto;
  padding: var(--lg) var(--md) var(--xl);
  display: flex;
  flex-direction: column;
  gap: var(--md);
}

/* The get-the-app line: slate on Night 2, never coral (docs/ux/web-join.md §5). */
.banner {
  display: flex;
  align-items: center;
  gap: var(--sm);
  padding: var(--xs) var(--md);
  background: var(--night-2);
  border-bottom: 1px solid var(--border);
  color: var(--slate);
  font-size: 1rem;
}

.banner-text {
  flex: 1;
  margin: 0;
}

.banner-close,
.banner-link {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--cream);
  font: inherit;
  font-weight: 700;
}

.banner-close {
  background: none;
  border: 0;
  cursor: pointer;
}

/* No underline: it ran through the descender of م in حمّل and made it read as ق. */
.banner-link {
  text-decoration: none;
}

.masthead {
  text-align: center;
}

.brand {
  margin: 0;
  color: var(--gold);
  font-family: "Lalezar", "Tajawal", sans-serif;
  font-size: 1.75rem;
  line-height: 1.3;
}

.welcome,
.tagline {
  margin: 0;
  font-size: 1.125rem;
}

.code {
  margin: var(--xs) 0 0;
  color: var(--gold);
  font-family: "Lalezar", sans-serif;
  font-size: 2.5rem;
  line-height: 1.2;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* G: the code was wrong, so it stops being the gold thing to check. */
.page[data-screen="gone"] .code {
  color: var(--slate);
}

.panel {
  margin: 0;
  padding: var(--md);
  background: var(--night-2);
  border: 1px solid var(--border);
  border-radius: var(--r-hero);
  display: flex;
  flex-direction: column;
  gap: var(--sm);
}

.panel-title {
  margin: 0;
  font-weight: 700;
}

.refusal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.refusal-body,
.hint,
.quiet {
  margin: 0;
  color: var(--slate);
}

.hint,
.quiet {
  text-align: center;
  font-size: 1rem;
}

input {
  width: 100%;
  min-height: 3.5rem;
  padding: var(--sm) var(--md);
  background: var(--night);
  color: var(--cream);
  border: 2px solid var(--border);
  border-radius: var(--r-control);
  font: inherit;
}

input::placeholder {
  color: var(--slate);
  opacity: 1;
}

input:focus {
  outline: none;
  border-color: var(--gold);
}

/* Invalid: the field and its line, together (docs/ux/join.md, Invalid). */
input[aria-invalid="true"] {
  border-color: var(--coral);
}

.field-error,
.panel-line {
  margin: 0;
  color: var(--coral);
  font-weight: 700;
}

.room-code {
  text-align: center;
  font-family: "Lalezar", "Tajawal", sans-serif;
  font-size: 1.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.room-code::placeholder {
  letter-spacing: 0.15em;
}

.avatars {
  display: grid;
  grid-template-columns: repeat(4, minmax(var(--tap), 1fr));
  gap: var(--sm);
}

.avatar {
  min-height: 3.5rem;
  background: var(--night);
  border: 2px solid var(--border);
  border-radius: var(--r-control);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

/* Chosen: ringed in gold, as in the app (docs/ux/join.md, Default). */
.avatar[aria-checked="true"] {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold);
}

.primary,
.secondary,
.text-button {
  min-height: var(--tap);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.primary,
.secondary {
  width: 100%;
  min-height: 3.5rem;
  padding: var(--sm) var(--lg);
  border-radius: var(--r-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* The one coral element on a screen (docs/02 §2). */
.primary {
  background: var(--coral);
  color: var(--night);
  border: 0;
}

.secondary {
  background: none;
  color: var(--cream);
  border: 2px solid var(--border);
}

.text-button {
  align-self: center;
  padding: var(--sm) var(--md);
  background: none;
  border: 0;
  color: var(--cream);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.primary:disabled,
.secondary:disabled {
  opacity: 0.6;
  cursor: wait;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: var(--sm);
}

.loading {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--md);
  padding-top: var(--lg);
}

.loading-line {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

/* Indeterminate: gold on Night 2, sliding from the start edge. */
.bar {
  position: relative;
  height: 6px;
  overflow: hidden;
  background: var(--night-2);
  border-radius: var(--r-pill);
}

.bar::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 40%;
  background: var(--gold);
  border-radius: var(--r-pill);
  animation: slide 1.4s ease-in-out infinite;
}

@keyframes slide {
  from {
    transform: translateX(150%);
  }

  to {
    transform: translateX(-250%);
  }
}

/*
 * T1: another tab has this room. Not a panel: nothing here is a form or a
 * refusal to act on, only a line to read and a wait (docs/ux/web-join.md, T1).
 */
.other-tab {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--md);
  padding-top: var(--lg);
}

.other-tab-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.other-tab-wait {
  margin: 0;
  color: var(--slate);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sm);
}

/* Small, slate, and turning: the page is waiting on the other tab. */
.spinner {
  flex: none;
  width: 1em;
  height: 1em;
  border: 2px solid var(--border);
  border-top-color: var(--slate);
  border-radius: 50%;
  animation: turn 1s linear infinite;
}

@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}

/* Still with reduced motion (docs/ux/web-join.md §9): a full bar, not moving. */
@media (prefers-reduced-motion: reduce) {
  .bar::after {
    width: 100%;
    animation: none;
    opacity: 0.6;
  }

  /* A still ring: the line beside it says what is being waited for. */
  .spinner {
    animation: none;
  }
}

/*
 * The wall's page (/m/CODE): pressed once, with a mouse or a TV remote, and
 * read from the sofa. Centred in the screen; on a phone the join page's
 * sizes, and on anything as wide as a laptop or a television, everything
 * scaled up with it, the code first (docs/ux/web-join.md §6).
 */
.page[data-route="wall"] {
  min-height: 100vh;
  justify-content: center;
}

.page[data-route="wall"] .code {
  font-size: 3.5rem;
}

@media (min-width: 60rem) {
  .page[data-route="wall"] {
    max-width: 48rem;
    gap: var(--xl);
    font-size: 1.5rem;
  }

  .page[data-route="wall"] .brand {
    font-size: 3rem;
  }

  .page[data-route="wall"] .code {
    font-size: 7rem;
  }

  .page[data-route="wall"] .primary,
  .page[data-route="wall"] .secondary {
    min-height: 6rem;
    font-size: 2.25rem;
    border-radius: var(--r-hero);
  }

  .page[data-route="wall"] .hint,
  .page[data-route="wall"] .refusal-body {
    font-size: 1.5rem;
  }

  .page[data-route="wall"] .refusal-title {
    font-size: 2rem;
  }

  .page[data-route="wall"] input {
    min-height: 5rem;
  }

  .page[data-route="wall"] .room-code {
    font-size: 3rem;
  }
}
