/* Root layout for the web app (F-18-2): the phone-width screen centered on any window. */
html,
body {
  height: 100%;
  margin: 0;
}
body {
  /* react-native-web: the app scrolls inside its ScrollViews, not the page */
  overflow: hidden;
  background: #e9e2d5;
}
#root {
  display: flex;
  flex: 1;
  height: 100%;
  max-width: 430px; /* = WEB_COLUMN_MAX (src/lib/useScreenSize.ts) */
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: #f4efe6;
}
/*
 * Until the app has drawn its first screen (bundle, then fonts): the splash itself (SCR-00, src/app/index.tsx), so
 * the page goes straight from this to the same picture instead of a small icon, a blank page, then the splash.
 * Nori 168 wide and the wordmark 64 high, centered as the splash column centers them; the airmail stripe at the
 * bottom. The root layout adds `booted` to <html> once it renders (src/app/_layout.tsx).
 */
html:not(.booted) #root {
  background:
    url(/boot/nori-envelope.webp) center calc(50% - 53px) / 168px auto no-repeat,
    url(/boot/logo-wordmark.webp) center calc(50% + 121px) / auto 64px no-repeat,
    repeating-linear-gradient(135deg, #d9502f 0 12px, #f4efe6 12px 18px, #24335a 18px 30px, #f4efe6 30px 36px) bottom / 100% 10px no-repeat,
    #f4efe6;
}
/*
 * react-native-web renders <Modal> (Sheet, dialogs) into a portal: a plain <div> appended to <body> (no id, no
 * inline style) whose child is position: fixed across the window. Keep it over the app column on wide windows.
 */
body > div:not([id]):not([style]) > * {
  left: max(0px, calc(50% - 215px)) !important;
  right: max(0px, calc(50% - 215px)) !important;
  /* the modal's own position: fixed layers then size to this box instead of the window */
  transform: translateZ(0);
  /* focused programmatically for the focus trap; it is not a control */
  outline: none;
}
/*
 * Keyboard focus (WCAG 2.4.7): react-native-web leaves the browser default, which is faint or missing on the paper
 * background. A 2px indigo (#24335A = colors.indigo) ring on what the keyboard reached; a tap or click shows none.
 * Text fields are left out: browsers match them on a tap too, and the blinking caret already shows where typing goes.
 * The modal box above is focused only for the focus trap, so it gets none either. Here because the CSP allows no
 * inline styles.
 */
:focus-visible:not(input):not(textarea) {
  outline: 2px solid #24335a !important;
  outline-offset: 2px;
}
body > div:not([id]):not([style]) > :focus-visible {
  outline: none !important;
}
/*
 * v3.13 운영 콘솔 SCR-87 (src/components/PrintSheet.web.tsx): the print sheet of 실물 엽서. On screen, the pages one
 * under another over the app; printed, only the pages, each on its own 100×148 mm sheet without margins (the card's
 * colors kept). A named page, so no other page of the app is ever printed at postcard size.
 * While the sheet is open the whole body is on that page and everything else on <body> is left out (11-12): Chrome
 * takes the paper and the "default" margins from the first page, and anything before the sheet (a script's element
 * on <body>) made that first page an empty Legal/Letter one, with margins that pushed each card's foot onto a page
 * of its own. The sheet must stay a direct child of <body> (PrintSheet.web appends it there), or it is left out too.
 */
@page nori-card {
  size: 100mm 148mm;
  margin: 0;
}
#nori-print-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: auto;
  background: #d8d0c0;
  padding-bottom: 32px;
}
#nori-print-sheet .nori-print-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
}
#nori-print-sheet .nori-print-page {
  page: nori-card;
  position: relative;
  width: 100mm;
  height: 148mm;
  margin: 20px auto 0;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 24px -12px rgba(30, 36, 51, 0.5);
}
@media print {
  html,
  body {
    height: auto;
    overflow: visible;
    background: #fff;
  }
  html.nori-print-on body {
    page: nori-card;
    margin: 0;
  }
  html.nori-print-on body > :not(#nori-print-sheet) {
    display: none !important;
  }
  #nori-print-sheet {
    position: static;
    overflow: visible;
    padding: 0;
    background: none;
  }
  #nori-print-sheet .nori-print-toolbar {
    display: none;
  }
  #nori-print-sheet .nori-print-page {
    margin: 0;
    box-shadow: none;
    break-after: page;
  }
  #nori-print-sheet .nori-print-page:last-child {
    break-after: auto;
  }
  #nori-print-sheet * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
