/* Dilly (web): the few global rules the browser needs and the phone does not. Nothing here changes how the app looks.

   LIGHT AND DARK. The page behind the app follows the look in effect, so there is never a white flash before dark and the browser's own parts (scrollbars, form controls, autofill, the focus ring
   and text selection) match. Which look: `html[data-theme]` when set (public/dilly-theme.js before the first paint, lib/web/htmlTheme.ts once the app runs, both from the app's own
   choice); otherwise the browser or Chromebook setting (prefers-color-scheme). The page color is TOKENS.page of lib/theme/palette.ts, the focus ring is a ring the page can always see. */
:root {
  color-scheme: light;
  --dilly-page: #fefefe;
  --dilly-boot: #e1fbcc;
  --dilly-focus: #1b1464;
  --dilly-focus-halo: #ffffff;
  --dilly-scroll: #c9c3ee;
  --dilly-select: #cfc6ff;
  --dilly-select-ink: #1b1464;
  --dilly-field: #ffffff;
  --dilly-field-ink: #06061f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --dilly-page: #0f0e29;
    --dilly-boot: #0f0e29;
    --dilly-focus: #d9d4ff;
    --dilly-focus-halo: #0f0e29;
    --dilly-scroll: #3b3a78;
    --dilly-select: #5a48d6;
    --dilly-select-ink: #ffffff;
    --dilly-field: #1d1c48;
    --dilly-field-ink: #f2f1ff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --dilly-page: #0f0e29;
  --dilly-boot: #0f0e29;
  --dilly-focus: #d9d4ff;
  --dilly-focus-halo: #0f0e29;
  --dilly-scroll: #3b3a78;
  --dilly-select: #5a48d6;
  --dilly-select-ink: #ffffff;
  --dilly-field: #1d1c48;
  --dilly-field-ink: #f2f1ff;
}

/* The react-native-web recommended reset (full height; the app's own scroll views scroll, never the page). It lives in this file, not in the page, so the Content-Security-Policy needs no inline style. */
html,
body {
  height: 100%;
  /* The visible height: on a phone or an iPad the browser's toolbar slides away and back, so a fixed 100vh would be taller than what is seen. dvh follows the toolbar (browsers that do not know it keep 100%). */
  height: 100dvh;
  overflow: hidden;
  /* No pull down to refresh and no rubber band past the app's own scrolling (the app's scroll views scroll, never the page). */
  overscroll-behavior: none;
}
/* The root clips what a screen draws past its edge (a big soft circle behind the companion picker, for one), so the page can never scroll sideways, not even when a key moves focus. */
#root {
  display: flex;
  height: 100%;
  flex: 1;
  position: relative;
  overflow: hidden;
}

html {
  background: var(--dilly-page);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--dilly-scroll) transparent;
}
body {
  margin: 0;
  background: var(--dilly-page);
  /* A tap or click never waits to see whether it is a double tap zoom; pinch zoom still works. */
  touch-action: manipulation;
  /* Like the phone app: words are not picked up by a drag or a double click. Text boxes below stay selectable. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}
::selection {
  background: var(--dilly-select);
  color: var(--dilly-select-ink);
}
/* Chrome paints an autofilled box pale blue or yellow with dark words; in dark that would be a pale block with words the app drew light. Keep the box on the card color. */
:root[data-theme="dark"] input:-webkit-autofill,
:root[data-theme="dark"] textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--dilly-field-ink);
  box-shadow: 0 0 0 1000px var(--dilly-field) inset;
  caret-color: var(--dilly-field-ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input:-webkit-autofill,
  :root:not([data-theme="light"]) textarea:-webkit-autofill {
    -webkit-text-fill-color: var(--dilly-field-ink);
    box-shadow: 0 0 0 1000px var(--dilly-field) inset;
    caret-color: var(--dilly-field-ink);
  }
}

/* The first moment, before the fonts and the app are ready: the same mint and the same mascot as the iPhone launch screen. */
#dilly-boot {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dilly-boot);
}
#dilly-boot img {
  width: min(200px, 40vw);
  height: auto;
  -webkit-user-drag: none;
}
/* The mascot picture was made on a mint square. On the dark page it is shown as a rounded mint tile (the same picture, no new art), so it reads as a tile and not as a pale block. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #dilly-boot img {
    border-radius: 24%;
    box-shadow: 0 0 60px rgba(124, 101, 239, 0.45);
  }
}
:root[data-theme="dark"] #dilly-boot img {
  border-radius: 24%;
  box-shadow: 0 0 60px rgba(124, 101, 239, 0.45);
}
#dilly-boot.dilly-boot-gone {
  display: none;
}

/* Pictures are art, not content to grab: no drag ghost, no selection highlight, no save-as menu target. */
img,
svg,
canvas,
[role="img"] {
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Keyboard focus: a clear ring on anything a person can reach with Tab. Only for the keyboard (:focus-visible), so a mouse or finger tap shows no ring. */
:focus {
  outline: none;
}
:focus-visible {
  outline: 3px solid var(--dilly-focus) !important;
  outline-offset: 3px !important;
  /* A second ring of the opposite color just inside the first, so the ring is visible on ANY surface: lavender on the dark page, but also on a gold celebration screen or a pale room wall,
     where the lavender alone is 1:1 (dark audit). The halo sits in the 3 pixel gap between the control and the outline. */
  box-shadow: 0 0 0 3px var(--dilly-focus-halo) !important;
}
input:focus-visible,
textarea:focus-visible {
  outline-offset: 2px !important;
}
/* A text field that draws its own focus ring on the box around it (components/school/doors/KidField.tsx, the sign in doors) says so with data-own-focus: the browser's square outline is then not drawn on top of it. */
[data-own-focus]:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* A mouse pointer shows a hand over anything that can be pressed. The look itself never changes on hover. */
[role="button"],
[role="link"],
[role="tab"],
[role="radio"],
[role="checkbox"],
[role="switch"],
a[href] {
  cursor: pointer;
}
[aria-disabled="true"] {
  cursor: default;
}

/* Reduce Motion (the Chromebook's own setting): the app already follows it for its animations; this also quiets anything made with plain CSS. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Nothing prints from here: a child's page is not a document. */
@media print {
  /* Whatever look the screen is in, paper is black on white (the teacher's cards and the school notice are printed from a page of their own, light, and stay that way). */
  html,
  body {
    background: #fff !important;
    color: #000 !important;
    color-scheme: light !important;
  }
  body {
    display: none;
  }
}

/* A mouse resting on a raised button or card lifts it a little (the pressable ones only: they carry data-raised, lib/a11y/webProps.ts). Pressing still sinks the face as it always did, and a finger
   never hovers, so a touch Chromebook sees none of this. Under Reduce Motion the lift is the same size but happens at once (the rule above). */
@media (hover: hover) and (pointer: fine) {
  [data-raised]:not([aria-disabled="true"]) {
    transition: transform 140ms cubic-bezier(0.33, 1, 0.68, 1);
  }
  [data-raised]:not([aria-disabled="true"]):hover:not(:active) {
    transform: translateY(-3px);
  }
  /* ...except in the row of the tab bar (the Classroom button beside it): the bar's row never moves. */
  [data-nav-still] [data-raised]:not([aria-disabled="true"]):hover:not(:active) {
    transform: none;
  }
}

/* The Room (components/room/webBits.ts HOVER_WEB): the spot chips and item tiles of decorating, and the shop's things and tags, answer a mouse resting on them with a soft shadow and a little brightness (a lift would fight the transform some of them carry while pressed); an
   object of the room glows softly (a lift would move the picture off its place). Mouse only, like the lift above. */
@media (hover: hover) and (pointer: fine) {
  [data-room-hover]:not([aria-disabled="true"]) {
    transition: filter 140ms ease;
  }
  [data-room-hover]:not([aria-disabled="true"]):hover:not(:active) {
    filter: brightness(1.04) drop-shadow(0 4px 5px rgba(40, 30, 100, 0.22));
  }
  [data-room-spot]:not([aria-disabled="true"]):hover:not(:active) {
    background-color: rgba(255, 255, 255, 0.22) !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 6px 18px rgba(40, 30, 100, 0.22);
    border-radius: 16px;
  }
}
