/* Mochi Bunny — 매거진 레이아웃 */

/* 글꼴은 설치 여부에 기대지 않고 폴더 안의 woff2를 쓴다 (둘 다 SIL OFL) */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/fraunces-latin-full-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/fraunces-latin-full-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Pretendard Variable";
  font-style: normal;
  font-weight: 45 920;
  font-display: swap;
  src: url("fonts/PretendardVariable.woff2") format("woff2-variations");
}

:root {
  --paper: #e9e5de;
  --ink: #1c1a17;
  --ink-2: #6b665e;
  --ink-3: #9a948a;
  --rule: rgba(28, 26, 23, 0.16);
  --accent: #c9788a;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --pad: clamp(20px, 3.4vw, 52px);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  opacity: 0;
  transition: opacity 0.9s ease;
  -webkit-user-select: none;
  user-select: none;
}
.ready #stage { opacity: 1; }

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 95% at 50% 46%, rgba(255, 252, 246, 0) 52%, rgba(74, 62, 50, 0.13) 100%);
}

/* ── 제목 ── */
.masthead {
  position: fixed;
  top: var(--pad);
  left: var(--pad);
  max-width: min(62vw, 760px);
  pointer-events: none;
}

.kicker {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 0 0 clamp(10px, 1.4vw, 20px);
  font-family: var(--serif);
  font-variation-settings: "opsz" 9, "SOFT" 100;
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}
.kicker span:first-child {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
.kicker span:first-child::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  margin-left: 14px;
  vertical-align: middle;
  background: var(--ink);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 340;
  font-size: clamp(54px, 8.6vw, 138px);
  line-height: 0.86;
  letter-spacing: -0.038em;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 0;
  text-wrap: balance;
}
h1 em {
  font-style: italic;
  font-weight: 300;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
}
h1 b {
  font-weight: inherit;
  color: var(--accent);
  transition: color 0.5s ease;
}

.deck {
  margin: clamp(14px, 1.7vw, 26px) 0 0;
  max-width: 34em;
  font-size: clamp(13px, 1.05vw, 15.5px);
  font-weight: 420;
  letter-spacing: -0.012em;
  color: var(--ink-2);
  word-break: keep-all;
}

/* ── 패널 ── */
.panel {
  position: fixed;
  top: 50%;
  right: var(--pad);
  width: 204px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.8s ease 0.25s;
}
.ready .panel { opacity: 1; }

.panel section {
  padding: 15px 0 16px;
  border-top: 1px solid var(--rule);
}
.panel section:last-child { border-bottom: 1px solid var(--rule); }

.panel h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 11px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.panel h2 i {
  font-family: var(--serif);
  font-variation-settings: "opsz" 9, "SOFT" 100;
  font-weight: 400;
  font-size: 12.5px;
  letter-spacing: 0;
  color: var(--ink-3);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, input:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 3px;
}

/* 도구: 잡기 / 콕 찌르기 */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px;
}
.seg button {
  height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 520;
  letter-spacing: -0.01em;
  color: var(--ink-2);
  transition: background 0.25s ease, color 0.25s ease;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] {
  background: var(--ink);
  color: #f4f0e9;
}

/* 색상 프리셋 */
.swatches {
  display: flex;
  align-items: center;
  gap: 10px;
}
.swatches button {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 46%),
    var(--c);
  box-shadow: inset 0 -2px 4px rgba(60, 40, 30, 0.14), 0 0 0 1px rgba(28, 26, 23, 0.1);
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.swatches button:hover { transform: scale(1.1); }
.swatches button:active { transform: scale(0.9, 0.84); }
.swatches button::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.swatches button[aria-checked="true"]::after { opacity: 1; transform: scale(1); }
.swatch-name {
  margin-left: auto;
  font-size: 12px;
  font-weight: 480;
  color: var(--ink-2);
  white-space: nowrap;
}

/* 슬라이더 */
.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  row-gap: 2px;
  font-size: 12px;
  font-weight: 480;
  color: var(--ink-2);
}
.slider + .slider { margin-top: 10px; }
.slider output {
  font-family: var(--serif);
  font-variation-settings: "opsz" 9, "SOFT" 100;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.slider input {
  grid-column: 1 / -1;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --v: 50%;
}
.slider input::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(to right, var(--ink) var(--v), var(--rule) var(--v));
}
.slider input::-moz-range-track { height: 1px; background: var(--rule); }
.slider input::-moz-range-progress { height: 1px; background: var(--ink); }
.slider input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1), background 0.2s ease;
}
.slider input::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
}
.slider input:hover::-webkit-slider-thumb { transform: scale(1.2); }
.slider input:active::-webkit-slider-thumb { background: var(--ink); transform: scale(1.1, 0.9); }

/* 동작 버튼 */
.panel .actions { padding: 0; }
.actions button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 38px;
  font-size: 12.5px;
  font-weight: 540;
  letter-spacing: -0.01em;
  text-align: left;
}
.actions button + button { border-top: 1px solid var(--rule); }
.actions button span {
  transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.actions button:hover span { transform: translateX(5px); }
.actions button:active span { transform: translateX(5px) scale(0.96, 0.9); }
kbd {
  font-family: var(--serif);
  font-variation-settings: "opsz" 9, "SOFT" 100;
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
  transition: color 0.2s ease;
}
.actions button:hover kbd { color: var(--accent); }

/* ── 아래쪽 안내 ── */
.foot {
  position: fixed;
  left: var(--pad);
  right: var(--pad);
  bottom: calc(var(--pad) - 6px);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  pointer-events: none;
  font-size: 11.5px;
  color: var(--ink-2);
}
.foot p { margin: 0; }
.hints {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  transition: opacity 0.8s ease;
}
.hints b {
  margin-right: 6px;
  font-weight: 620;
  color: var(--ink);
}
[data-tool="grab"] .when-poke, [data-tool="poke"] .when-grab { display: none; }
.status {
  font-family: var(--serif);
  font-variation-settings: "opsz" 9, "SOFT" 100;
  font-style: italic;
  font-size: 12.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.failed .status { color: #a2372f; font-style: normal; white-space: normal; }

/* ── 좁은 화면: 패널을 아래로 ── */
@media (max-width: 820px) {
  .masthead { max-width: calc(100vw - var(--pad) * 2); }
  h1 { font-size: clamp(44px, 13.5vw, 84px); }
  .panel {
    top: auto;
    left: var(--pad);
    right: var(--pad);
    bottom: calc(var(--pad) + 18px);
    width: auto;
    transform: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "tool flavor" "feel actions";
    column-gap: 22px;
    align-items: start;
  }
  .panel section { padding: 10px 0 11px; }
  .panel section:nth-child(1) { grid-area: tool; }
  .panel section:nth-child(2) { grid-area: flavor; align-self: stretch; }
  .panel section:nth-child(3) { grid-area: feel; border-bottom: 0; }
  .panel .actions { grid-area: actions; border-bottom: 0; }
  .panel h2 { margin-bottom: 8px; }
  .panel h2 i { display: none; }
  .swatch-name { display: none; }
  .actions button { height: 31px; }
  .slider + .slider { margin-top: 4px; }
  kbd, .hints { display: none; }
  .foot { justify-content: flex-end; bottom: calc(var(--pad) - 10px); }
}

@media (max-height: 560px) and (min-width: 821px) {
  .panel section { padding: 9px 0 10px; }
  .actions button { height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
