/* The sign-in screen.
 *
 * An eight-year-old opens this every practice day, so it is warm rather than
 * administrative: daylight blue, a rounded card, a trail climbing a hill towards a
 * flag. Nothing bounces or demands attention — the page a child sees before working
 * should feel calm, not like a game asking to be played.
 *
 * Everything is drawn in CSS and inline SVG. No image files, no web fonts, nothing
 * fetched: the page appears at once on a phone on mobile data, and the Content-
 * Security-Policy can stay as tight as it is.
 */
:root {
  color-scheme: light;
  --ink: #163259;
  --muted: #5c7290;
  --sky-top: #cfe6ff;
  --sky-bottom: #eaf4ff;
  --card: #ffffff;
  --line: #dbe7f6;
  --sun: #ffd166;
  --hill: #7cc4a4;
  --hill-dark: #55a583;
  --trail: #f6b352;
  --warn-bg: #fff2e2;
  --warn-ink: #8a4b12;
  --shadow: 0 18px 40px rgba(22, 50, 89, 0.12);
  /* The one strong colour on the page: the child's own sign-in button. Dark enough to
     carry white text in both themes, which --trail (a light orange) is not. */
  --go: #1f4f9c;
  --go-hover: #17407f;
}

/* Dark mode, kept as evening rather than as a dark box: the sky stays a sky, the
   card lifts off it, and the text has enough contrast to read at arm's length. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f2f6fc;
    --muted: #b9cbe4;
    --sky-top: #2a3f63;
    --sky-bottom: #1a2942;
    --card: #24395c;
    --line: #3a5480;
    --sun: #ffd166;
    --hill: #6fb897;
    --hill-dark: #4b9578;
    --trail: #f6b352;
    --warn-bg: #4a3220;
    --warn-ink: #ffd9a8;
    --go: #4d8bdc;
    --go-hover: #6ea3e8;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  --go: #4d8bdc;
  --go-hover: #6ea3e8;
  --ink: #f2f6fc;
  --muted: #b9cbe4;
  --sky-top: #2a3f63;
  --sky-bottom: #1a2942;
  --card: #24395c;
  --line: #3a5480;
  --warn-bg: #4a3220;
  --warn-ink: #ffd9a8;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
}

/* `hidden` has to win.
   A class that sets `display` beats the browser's own rule for the hidden attribute,
   so this box was on screen everywhere — including the live site, where nothing wires
   its buttons up. That is precisely "it appears but does not click". Any element in
   this page carrying `hidden` is hidden, and that rule is stated first so nothing
   below can quietly outrank it. */
[hidden] { display: none !important; }

/* Padding counts inside the width, everywhere.
   `main` is `width: min(420px, 100%)` with 30px of padding either side, and without
   this that is 480px of element inside a 390px phone — the card hung 11px off each
   edge and the page scrolled sideways. */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  background: linear-gradient(170deg, var(--sky-top), var(--sky-bottom) 62%);
  color: var(--ink);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

/* Three soft clouds drifting behind the card. Slow enough to be scenery. */
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

.cloud {
  position: absolute;
  background: #fff;
  border-radius: 999px;
  opacity: 0.55;
  filter: blur(0.3px);
  animation: drift linear infinite;
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 999px;
}
.c1 { width: 130px; height: 40px; top: 12%; left: -180px; animation-duration: 90s; }
.c1::before { width: 62px; height: 62px; top: -26px; left: 26px; }
.c1::after  { width: 44px; height: 44px; top: -16px; left: 74px; }
.c2 { width: 96px; height: 30px; top: 34%; left: -140px; animation-duration: 130s;
      animation-delay: -40s; opacity: 0.4; }
.c2::before { width: 46px; height: 46px; top: -20px; left: 18px; }
.c2::after  { width: 34px; height: 34px; top: -12px; left: 54px; }
.c3 { width: 150px; height: 46px; top: 72%; left: -200px; animation-duration: 160s;
      animation-delay: -90s; opacity: 0.3; }
.c3::before { width: 70px; height: 70px; top: -30px; left: 30px; }
.c3::after  { width: 50px; height: 50px; top: -18px; left: 86px; }

@keyframes drift { to { transform: translateX(calc(100vw + 240px)); } }

@media (prefers-reduced-motion: reduce) {
  .cloud { animation: none; }
  .trail { stroke-dasharray: none; animation: none; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cloud { opacity: 0.08; }
}

main {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 34px 30px 30px;
  width: min(420px, 100%);
  text-align: center;
  box-shadow: var(--shadow);
}

/* The trail draws itself once, in a little over a second, then stays put. */
.mark { width: 132px; height: 132px; display: block; margin: 0 auto 6px; }
.sun   { fill: var(--sun); }
.hill  { fill: var(--hill); }
.trail {
  fill: none;
  stroke: var(--trail);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 150;
  stroke-dashoffset: 150;
  animation: draw 1.4s 0.2s ease-out forwards;
}
.pole  { stroke: var(--hill-dark); stroke-width: 3.5; stroke-linecap: round; }
.cloth { fill: #ef6f6c; }
.flag  { opacity: 0; animation: appear 0.4s 1.5s ease-out forwards; }

@keyframes draw   { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }

h1 {
  margin: 0;
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tagline {
  margin: 2px 0 26px;
  color: var(--muted);
  font-size: 1.05rem;
}

/* The child's form.
 *
 * Big fields and a big button: this is used by a seven-year-old on a phone, every day.
 * The inputs are left-to-right because a username and a password are typed in Latin
 * characters even on a Hebrew page, while their labels stay with the page.
 */
.child-login {
  display: block;
  margin: 0 0 4px;
  text-align: start;
}
.child-login .field {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
}
.child-login input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 14px;
  padding: 13px 14px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  direction: ltr;
  text-align: left;
}
.child-login input:focus-visible {
  outline: 3px solid var(--trail);
  outline-offset: 2px;
}
.child-submit {
  width: 100%;
  margin: 4px 0 0;
  padding: 14px 20px;
  min-height: 52px;
  border: none;
  border-radius: 16px;
  background: var(--go);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
}
.child-submit:hover { background: var(--go-hover); }
.child-submit:disabled { opacity: 0.6; cursor: default; }
.child-error {
  margin: 12px 0 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 0.95rem;
  text-align: start;
}

/* The parent's way in, below the child's, with a divider that says so. */
.or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
}
.or::before, .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.signin-button {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  /* Google's button places its logo and its label assuming left-to-right, and this
     page is right-to-left, so the two were laid out on top of each other — the word
     "Sign in" printed across the G. The widget is given the direction it was built
     for; the page around it stays as it is. */
  direction: ltr;
}

/* A hard ceiling on Google's markup.
   Its button brings its own stylesheet, and when that stylesheet does not arrive —
   blocked, slow, changed — the raw markup is an <svg> with no width and a label
   printed twice, which filled the whole card. These rules are what the page looks
   like when someone else's CSS is missing, so they are stated rather than assumed. */
.signin-button > * { max-width: 100%; }
.signin-button svg { width: 20px; height: 20px; flex: none; }
.signin-button [role="button"],
.signin-button div[tabindex] {
  max-width: 280px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.signin-hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.status {
  margin: 22px 0 0;
  padding: 13px 15px;
  border-radius: 14px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  text-align: start;
  font-size: 0.98rem;
}

.dev-login {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.dev-label {
  width: 100%;
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.82rem;
}
.dev-login button { margin-top: 0; }

.account-id { margin-top: 14px; text-align: start; }
.account-label { margin: 0 0 6px; color: var(--muted); font-size: 0.9rem; }

code {
  display: block;
  direction: ltr;
  text-align: left;
  background: var(--sky-bottom);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  font: 0.95rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

button {
  margin-top: 10px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  min-height: 44px;
}
button:hover { background: var(--sky-bottom); }
button:focus-visible { outline: 3px solid var(--trail); outline-offset: 2px; }

@media (max-width: 380px) {
  main { padding: 26px 20px 24px; border-radius: 22px; }
  .mark { width: 108px; height: 108px; }
  h1 { font-size: 2.2rem; }
}
