/*
 * Global styles for the web app only (linked from public/index.html). Everything the screens
 * draw comes from the design system in src/constants/theme.ts; this file covers what a browser
 * adds on top: the page frame, what shows before the app starts, hover, and keyboard focus.
 * Colours repeat the theme's Daybreak and Dusk tokens.
 */

/* --- Page frame (react-native-web's root setup) ------------------------------------------ */
html,
body {
  height: 100%;
}
body {
  margin: 0;
  overflow: hidden; /* screens scroll inside themselves */
  overscroll-behavior: none;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
}
#root {
  display: flex;
  height: 100%;
  flex: 1;
}

/* --- Tokens ------------------------------------------------------------------------------- */
:root {
  --sky: linear-gradient(160deg, #fff1e8 0%, #fde3e0 46%, #ece1f4 100%);
  --sky-fallback: #fde3e0;
  --focus: #a8385a;
  --hover: brightness(0.965);
  --selection: #f9856055;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sky: linear-gradient(160deg, #33152b 0%, #1d1129 46%, #120b1d 100%);
    --sky-fallback: #1d1129;
    --focus: #ffa486;
    --hover: brightness(1.14);
    color-scheme: dark;
  }
}
/* Once the app runs it sets data-theme from Settings → Appearance, which can differ from the
   browser's own preference. */
html[data-theme='light'] {
  --sky: linear-gradient(160deg, #fff1e8 0%, #fde3e0 46%, #ece1f4 100%);
  --sky-fallback: #fde3e0;
  --focus: #a8385a;
  --hover: brightness(0.965);
  color-scheme: light;
}
html[data-theme='dark'] {
  --sky: linear-gradient(160deg, #33152b 0%, #1d1129 46%, #120b1d 100%);
  --sky-fallback: #1d1129;
  --focus: #ffa486;
  --hover: brightness(1.14);
  color-scheme: dark;
}

/* --- Before the app starts ----------------------------------------------------------------- */
body {
  background: var(--sky-fallback) var(--sky) fixed;
}
#root:empty::before {
  content: '';
  margin: auto;
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: url('/icon-192.png') center / cover no-repeat;
  box-shadow: 0 24px 48px -16px #5a236c47;
}
.noscript {
  margin: 20vh auto 0;
  max-width: 28rem;
  padding: 0 1.5rem;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.5;
}

/* --- Keyboard focus: one brand-coloured ring, and only for the keyboard --------------------- */
:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
/* Text fields draw their own accent border when focused (TextField). */
input:focus-visible,
textarea:focus-visible {
  outline: none;
}

/* --- Hover, for devices that have it ------------------------------------------------------- */
button,
a,
[role='button'],
[role='link'],
[role='tab'],
[role='checkbox'],
[role='radio'],
[role='switch'] {
  transition:
    filter 120ms ease,
    opacity 120ms ease;
}
@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):not([aria-disabled='true']):hover,
  [role='button']:not([aria-disabled='true']):hover,
  [role='tab']:hover,
  [role='checkbox']:hover,
  [role='radio']:hover,
  [role='switch']:hover {
    filter: var(--hover);
  }
  a[href]:hover,
  [role='link']:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

::selection {
  background: var(--selection);
}

/* --- Printing -------------------------------------------------------------------------------
   Exports print from their own hidden frame (src/features/export/share.web.ts). If someone
   prints a screen directly, let the page flow instead of clipping to the window. */
@media print {
  html,
  body,
  #root {
    height: auto;
  }
  body {
    overflow: visible;
    background: #fff;
  }
}
