/*
  모든 화면에 공통으로 쓰는 기본 스타일입니다.
  색과 크기는 css/tokens.css의 변수로만 씁니다.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--fill);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  color: var(--ink);
  background: var(--fill);
  /* 한글은 낱말 중간에서 줄을 바꾸지 않습니다. 너무 긴 낱말만 예외로 끊습니다. */
  word-break: keep-all;
  overflow-wrap: anywhere;
}

h1,
p,
ul,
dl,
dd {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* 키보드로 이동할 때 지금 어디에 있는지 보이게 합니다. */
:focus-visible {
  outline: var(--focus-width) solid var(--ink);
  outline-offset: var(--focus-width);
}

/* 화면이 바뀔 때 코드가 제목으로 초점을 옮깁니다. 그때는 테두리를 그리지 않습니다. */
h1:focus {
  outline: none;
}

/* 화면 틀: 핸드폰에서는 꽉 차고, PC에서는 가운데에 최대 폭으로 보입니다. */
.app {
  display: flex;
  flex-direction: column;
  max-width: var(--screen-max);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 var(--gutter);
  background: var(--bg);
}

.app-main {
  flex: 1;
}

/* 위쪽 줄 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
}

.brand {
  font-size: var(--text-list);
  font-weight: var(--weight-bold);
}

/* 선으로 그린 아이콘 */
.icon {
  display: inline-flex;
}

.icon svg {
  width: var(--icon-size);
  height: var(--icon-size);
  stroke-width: var(--icon-stroke);
}

/* 아이콘만 있는 버튼(뒤로 가기 등). 누르는 영역은 넓게, 아이콘은 왼쪽 여백 선에 맞춥니다. */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  margin-left: calc((var(--icon-size) - var(--tap-min)) / 2);
}

/* 버튼: 브라우저의 기본 모양을 지우고 필요한 것만 다시 입힙니다. */
button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation; /* 빠르게 두 번 눌러도 화면이 확대되지 않게 합니다. */
}

button:disabled {
  cursor: default;
}

/* 주 버튼: 화면의 주된 행동 하나 */
.button-primary {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--button-height);
  border-radius: var(--radius-box);
  background: var(--ink);
  font-size: var(--text-list);
  font-weight: var(--weight-bold);
  color: var(--bg);
}

.button-primary:disabled,
.button-secondary:disabled {
  background: var(--button-disabled-bg);
  color: var(--button-disabled-ink);
}

/* 보조 버튼 */
.button-secondary {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--button-sub-height);
  border-radius: var(--radius-box);
  background: var(--fill);
  font-size: var(--text-list);
  font-weight: var(--weight-semibold);
}

/* 작은 선택 버튼 (빠른 추가, 목표 고르기) */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--quick-height);
  padding: 0 var(--gap-item);
  border-radius: var(--radius-quick);
  background: var(--fill);
  font-size: var(--text-sub);
  font-weight: var(--weight-semibold);
}

.chip:active {
  background: var(--line);
}

/* 지금 골라져 있는 것 */
.chip[aria-pressed='true'] {
  background: var(--ink);
  color: var(--bg);
}

/* 글자만 있는 버튼 ("내 기록", "기록 내보내기" 등). 누르는 영역은 넉넉하게 둡니다. */
.text-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  font-size: var(--text-sub);
  font-weight: var(--weight-semibold);
}

.text-button:disabled {
  color: var(--chevron);
}

/* 문장 안의 링크 */
.inline-link {
  font-weight: var(--weight-semibold);
  text-decoration: underline;
}

/* 좋은 쪽으로의 변화. 색으로만 알리지 않고 "올랐어요"라는 말을 함께 씁니다. */
.positive {
  color: var(--positive);
}

/* 화면에는 보이지 않지만 화면 읽기 프로그램은 읽는 글자 */
.visually-hidden {
  position: absolute;
  width: var(--hairline);
  height: var(--hairline);
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* 안내 문장 */
.notice {
  padding: var(--gap-block) 0;
  font-size: var(--text-desc);
  color: var(--sub);
}

/* 맨 아래 안내 한 줄 */
.footnote {
  padding: var(--gap-block) 0;
  font-size: var(--text-note);
  color: var(--sub);
}

/* 위쪽 줄의 오른쪽 끝에 두는 아이콘 버튼(홈으로). 아이콘을 오른쪽 여백 선에 맞춥니다. */
.icon-button-end {
  margin-left: auto;
  margin-right: calc((var(--icon-size) - var(--tap-min)) / 2);
}
