/* 모든 화면이 같이 쓰는 바닥: 글꼴 선언, 화면 고정, 안전 영역, 앱을 담는 판.
   색과 크기는 tokens.css 에 있다. 화면마다의 모양은 화면의 CSS 에 둔다.

   화면을 만드는 사람이 알아 둘 것
     - 모든 요소가 touch-action: none 이다. 두 번 눌러 확대, 끌어서 넘기기, 당겨서 새로 고침이 없다.
       세로로 넘겨 봐야 하는 곳(홈의 목록 등)에는 class="scroll-y" 를 붙인다. 그 안에서만 넘어간다.
     - 안전 영역은 env() 를 직접 쓰지 않고 var(--safe-top) 처럼 변수로 쓴다. 토스와 앱 껍데기에서는
       platform 이 이 변수에 값을 넣는다.
     - 글자를 고를 수 없다(user-select: none). 고를 수 있어야 하는 곳은 그 요소에서 푼다. */

/* ---------- 글꼴 ----------
   쓰는 글자만 남긴 파일이다. web/tools/build-fonts.js 가 web/assets/fonts/vendor/ 의 원본에서 만든다.
   파일 이름이 바뀌지 않으므로 이 선언은 손으로 고칠 일이 없다.

   Pretendard — Copyright (c) 2021 Kil Hyung-jin, SIL Open Font License 1.1
   Jua — Copyright 2018 The BM JUA Project Authors, SIL Open Font License 1.1
   전문: web/assets/fonts/vendor/Pretendard-LICENSE.txt, Jua-OFL.txt (내보내는 묶음에도 글꼴 옆에 함께 둔다) */
@font-face {
  font-family: 'Pretendard';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../../../fonts/pretendard.subset.9b34b9f1df.ttf') format('truetype');
}
@font-face {
  font-family: 'Jua';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../../fonts/jua.subset.50434064de.ttf') format('truetype');
}

/* ---------- 안전 영역 ----------
   노치와 홈 막대를 피하는 여백. 웹에서는 브라우저가 주는 값이다. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* ---------- 화면 고정 ----------
   touch-action 은 물려받지 않는다. 모든 요소에 걸어야 어디를 두 번 눌러도 확대되지 않는다.
   두 손가락 확대는 index.html 의 viewport 와 머리의 스크립트가 같이 막는다. */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none; /* 당겨서 새로 고침과 끝에서 튕기는 것을 막는다 */
}
body {
  position: fixed;
  inset: 0;
  background: var(--surface);
  color: var(--text);
  font: var(--type-aux);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* 안드로이드 앱 안(index.html 이 in-app 을 붙임)에서는 첫 화면이 준비되기 전까지 바탕을 비운다. 그동안 앱의 창 바탕(시스템
   스플래시와 같은 물색과 아이콘, android/…/launch_background.xml)이 비쳐, 스플래시가 걷혀도 아이콘이 첫 화면까지 이어진다. */
html.in-app:not(.is-ready),
html.in-app:not(.is-ready) body {
  background: transparent;
}
button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
[hidden] {
  display: none !important;
}

/* 세로로 넘겨 보는 곳. 안의 요소도 같이 풀어야 손가락이 어디에 닿든 넘어간다. */
.scroll-y {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.scroll-y,
.scroll-y * {
  touch-action: pan-y;
}

/* ---------- 앱을 담는 판 ----------
   한 열. 내용의 최대 폭은 476 이고 넓은 화면에서는 가운데에 둔다. main.js 가 화면을 이 안에 끼운다.
   글꼴과 문장이 준비되기 전에는 보이지 않다가 html 에 is-ready 가 붙으면 나타난다.
   준비 전 불투명도는 0 이 아니라 0.01 이다(눈에는 안 보인다). 크롬(안드로이드 웹뷰 포함)은 글이나 그림이 처음 그려질 때까지
   화면을 내보내지 않고 기다리는데(최대 약 0.5초), 불투명도 0 은 그려진 것으로 치지 않는다. 0 이면 앱에서 첫 화면이
   0.35초 늦게 보였다(WEB.md "켤 때"). */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: var(--shell);
  margin: 0 auto;
  opacity: 0.01;
  transition: opacity var(--motion-micro) var(--ease-enter);
}
.is-ready .app {
  opacity: 1;
}

/* 화면이 아직 없을 때와 문장을 못 불러왔을 때 main.js 가 보여 주는 한 줄. */
.boot-note {
  margin: auto;
  padding: var(--space-xl) var(--gutter);
  color: var(--text-muted);
  font: var(--type-aux);
  text-align: center;
  word-break: keep-all;
}
/* 문제 화면을 열려는데 사전이 아직일 때 화면 아래에 뜨는 한 줄(main.js 의 lexiconReady). 0.2초 넘게 기다릴 때만 나타난다.
   지금 화면 위에 떠 있고 자리를 차지하지 않는다. */
.wait-note {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + var(--space-xl));
  transform: translateX(-50%);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  color: var(--text-muted);
  font: var(--type-aux);
  white-space: nowrap;
  animation: ui-fade var(--motion-short) var(--ease-enter) both;
}
.boot-note button {
  display: block;
  min-height: var(--touch);
  margin: var(--space-md) auto 0;
  padding: 0 var(--space-lg);
  border-radius: var(--radius-full);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  font: var(--type-label);
}
