/*
 * components.css — Reusable UI Components
 * 모든 페이지에서 공통으로 쓰이는 컴포넌트.
 * 페이지별 고유 스타일은 home.css / chapter.css 에 작성합니다.
 */

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

body {
  font-family: var(--f-sans);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a   { color: inherit; text-decoration: none; }

/* ═══════════════════════════════════════
   Scroll Reveal
═══════════════════════════════════════ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.75s ease, transform 0.75s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ═══════════════════════════════════════
   Global Nav
═══════════════════════════════════════ */
.g-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) var(--s6);
  background: rgba(255, 251, 246, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
  transform: translateY(-100%);
  transition: transform 0.4s ease, border-color 0.3s ease;
}
.g-nav.is-shown {
  transform: translateY(0);
  border-color: var(--c-border);
}
.g-nav__logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--c-text);
}
.g-nav__logo:hover { color: var(--accent); }

.g-nav__tabs {
  display: flex;
  gap: var(--s1);
  background: var(--accent-sub);
  padding: 3px;
  border-radius: var(--r-full);
}
.g-nav__tab {
  padding: 6px 18px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 700;
  color: var(--c-muted);
  transition: all 0.2s ease;
}
.g-nav__tab.is-active,
.g-nav__tab:hover {
  background: var(--accent);
  color: #fff;
}

/* ═══════════════════════════════════════
   Badge
═══════════════════════════════════════ */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: var(--r-full);
  line-height: 1;
}
.badge--accent  { color: #fff;            background: var(--accent); }
.badge--subtle  { color: var(--accent);   background: var(--accent-sub); }
.badge--blue    { color: #fff;            background: var(--c-blue); }
.badge--blue-sub{ color: var(--c-blue);   background: var(--c-blue-sub); }
.badge--locked  { color: var(--c-locked); background: var(--c-locked-bg); }

/* ═══════════════════════════════════════
   Place Card
═══════════════════════════════════════ */
.place-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.place-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--sh-accent);
}
.place-card__img {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--accent-sub);
  display: flex;
  align-items: center;
  justify-content: center;
}
.place-card__img img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.place-card:hover .place-card__img img { transform: scale(1.05); }
.place-card__placeholder { font-size: 44px; opacity: 0.35; }

.place-card__body  { padding: var(--s5); }
.place-card__body h4 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  margin: var(--s2) 0 var(--s1);
}
.place-card__body h4 small {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--c-muted);
  margin-top: 2px;
}
.place-card__addr {
  font-size: 11px;
  color: var(--c-muted);
  margin-bottom: var(--s2);
}
.place-card__desc {
  font-size: 13px;
  line-height: 1.85;
}

/* ═══════════════════════════════════════
   Timeline
═══════════════════════════════════════ */
.timeline {
  position: relative;
  padding-left: var(--s10);
}
.timeline::before {
  content: '';
  position: absolute;
  left: 11px; top: 16px; bottom: 16px;
  width: 2px;
  background: var(--accent-sub);
}
.timeline__item {
  position: relative;
  padding-bottom: var(--s10);
}
.timeline__item::before {
  content: '';
  position: absolute;
  left: calc(var(--s10) * -1 + 3px);
  top: 10px;
  width: 16px; height: 16px;
  background: var(--c-surface);
  border: 3px solid var(--accent);
  border-radius: 50%;
}
.timeline__item time {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  background: var(--accent);
  padding: 3px 12px;
  border-radius: var(--r-full);
  margin-bottom: var(--s2);
}
.timeline__item h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--s1);
}
.timeline__item p {
  font-size: 14px;
  color: var(--c-muted);
  line-height: 1.9;
}

/* ═══════════════════════════════════════
   Memory Card (메시지 카드)
   타임라인 사이에 자연스럽게 삽입
═══════════════════════════════════════ */
.memory {
  margin: var(--s10) 0 var(--s12);
}
.memory__inner {
  background: var(--c-surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: var(--s8) var(--s8) var(--s6);
  box-shadow: var(--sh-sm);
  position: relative;
  max-width: 520px;
}
.memory__inner::before {
  content: '"';
  position: absolute;
  top: 4px; left: var(--s5);
  font-family: var(--f-serif);
  font-size: 64px;
  color: var(--accent-sub);
  line-height: 1;
  pointer-events: none;
}
.memory__text {
  font-family: var(--f-serif);
  font-size: 15px;
  line-height: 2.1;
  padding-top: var(--s4);
  margin-bottom: var(--s4);
}
.memory__text .jp  { color: var(--c-text); }
.memory__text .kr  { color: var(--accent-text); font-weight: 600; }
.memory__text .dialect {
  display: inline-block;
  font-family: var(--f-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--c-blue);
  background: var(--c-blue-sub);
  padding: 1px 8px;
  border-radius: var(--r-full);
  vertical-align: middle;
}
.memory__cite {
  font-size: 12px;
  color: var(--c-faint);
  font-style: normal;
}

/* ═══════════════════════════════════════
   Scroll Hint
═══════════════════════════════════════ */
.scroll-hint {
  position: absolute;
  bottom: var(--s10);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s1);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--c-muted);
  animation: sh-bounce 2.4s ease-in-out infinite;
}
.scroll-hint .arrow { font-size: 14px; }
@keyframes sh-bounce {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50%     { transform: translateX(-50%) translateY(8px); }
}

/* ═══════════════════════════════════════
   Korean Cheat Sheet — Float Button
═══════════════════════════════════════ */
.k-btn {
  position: fixed;
  bottom: var(--s8);
  right: var(--s6);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  font-family: var(--f-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text);
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.k-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

/* Korean Cheat Sheet — Panel */
.k-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
}
.k-panel.is-open { display: block; }

.k-panel__overlay {
  position: absolute;
  inset: 0;
  background: rgba(35, 24, 24, 0.5);
  backdrop-filter: blur(4px);
}
.k-panel__drawer {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: min(460px, 100vw);
  background: var(--c-surface);
  display: flex;
  flex-direction: column;
  animation: panel-in 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes panel-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.k-panel__head {
  position: sticky; top: 0;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: var(--s8) var(--s6) var(--s5);
  flex-shrink: 0;
}
.k-panel__head h2  { font-size: 18px; font-weight: 700; margin-bottom: var(--s1); }
.k-panel__head p   { font-size: 13px; color: var(--c-muted); }
.k-panel__close {
  position: absolute;
  top: var(--s5); right: var(--s5);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-bg);
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.k-panel__close:hover { background: var(--accent-sub); }

.k-panel__body {
  padding: var(--s6);
  overflow-y: auto;
  flex: 1;
}

/* Phrase group */
.k-group         { margin-bottom: var(--s8); }
.k-group__title  {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--c-muted);
  margin-bottom: var(--s4);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--c-border);
}

/* Phrase item — 3열: 일본어 / 표준어 / 부산말 */
.k-phrase {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--s4);
  row-gap: var(--s1);
  align-items: center;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--c-bg);
  margin-bottom: var(--s2);
  transition: background 0.2s;
}
.k-phrase:hover { background: var(--accent-sub); }
.k-phrase--special { background: var(--accent-sub); }

.k-phrase__jp {
  font-size: 13px;
  color: var(--c-muted);
  grid-column: 1; grid-row: 1;
}
.k-phrase__std {
  font-size: 16px;
  font-weight: 700;
  grid-column: 2; grid-row: 1;
}
.k-phrase__busan {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-blue);
  grid-column: 3; grid-row: 1;
  display: flex; align-items: center; gap: 4px;
}
.k-phrase__busan::before {
  content: '🍊';
  font-size: 12px;
}
.k-phrase__busan:empty::before  { content: none; }
.k-phrase__busan:empty          { display: none; }
.k-phrase__read-busan:empty     { display: none; }
.k-phrase:has(.k-phrase__busan:empty) {
  grid-template-columns: auto 1fr;
}
.k-phrase__read-std {
  font-size: 11px;
  color: var(--c-muted);
  font-weight: 600;
  grid-column: 2; grid-row: 2;
}
.k-phrase__read-busan {
  font-size: 11px;
  color: var(--c-blue);
  font-weight: 600;
  grid-column: 3; grid-row: 2;
}

/* ═══════════════════════════════════════
   Password Gate
═══════════════════════════════════════ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: clamp(140px, 22vh, 220px);
  overflow: hidden;
  /* acorn theme override */
  --accent:     #8B5E3C;
  --accent-sub: #F0DDD0;
}
.gate.is-opening {
  animation: door-open 1.15s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}
@keyframes door-open {
  0%   { opacity: 1; transform: scale(1);    filter: brightness(1)   blur(0px); }
  16%  { opacity: 1; transform: scale(1);    filter: brightness(0.6) blur(0px); }
  58%  { opacity: 0.9; transform: scale(1.05); filter: brightness(1.6) blur(1px); }
  100% { opacity: 0;   transform: scale(1.18); filter: brightness(4)   blur(5px); }
}

.gate__photo {
  position: absolute;
  inset: 0;
  background-image: url('../docs/korea/KakaoTalk_20260427_234336474.png');
  background-size: auto 62vh;
  background-repeat: no-repeat;
  background-position: center top;
  background-color: #0e0b09;
  animation: photo-ken 22s ease-in-out infinite alternate;
}
@keyframes photo-ken {
  from { transform: scale(1)    translateY(0%); }
  to   { transform: scale(1.07) translateY(-1.5%); }
}

.gate__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 68% 88% at 50% 50%, rgba(5,5,4,0.20) 0%, rgba(5,5,4,0.74) 100%),
    linear-gradient(to bottom, rgba(5,5,4,0.40) 0%, transparent 38%, transparent 62%, rgba(5,5,4,0.46) 100%);
}

.gate__card {
  position: relative;
  z-index: 1;
  width: min(400px, calc(100vw - 24px));
  background: rgba(255, 252, 248, 0.93);
  backdrop-filter: blur(32px) saturate(1.7);
  -webkit-backdrop-filter: blur(32px) saturate(1.7);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 28px;
  padding: 44px 40px 36px;
  text-align: center;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.5) inset,
    0 2px 4px  rgba(0,0,0,0.1),
    0 12px 36px rgba(0,0,0,0.36),
    0 44px 80px rgba(0,0,0,0.24);
  animation: card-in 0.72s cubic-bezier(0.34, 1.28, 0.64, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(30px) scale(0.93); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.gate__keyhole {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 auto var(--s5);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139,94,60,0.48);
  transition: background 0.4s, box-shadow 0.4s, transform 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.gate__keyhole.is-unlocking {
  background: #C8922A;
  box-shadow: 0 4px 24px rgba(200,146,42,0.60);
  transform: scale(1.14);
}
.gate__leaf-icon { width: 26px; height: 32px; }
.gate__keyhole.is-unlocking .gate__leaf-icon {
  animation: leaf-sway 0.7s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}
@keyframes leaf-sway {
  0%   { transform: rotate(0deg)   scale(1);    }
  25%  { transform: rotate(-18deg) scale(0.88); }
  65%  { transform: rotate(24deg)  scale(1.18); }
  100% { transform: rotate(8deg)   scale(1);    }
}

.gate__hint {
  display: inline-block;
  font-size: 11px;
  color: var(--c-muted);
  background: rgba(139,94,60,0.07);
  padding: 5px 14px;
  border-radius: var(--r-full);
  border: 1px solid rgba(139,94,60,0.14);
  margin-bottom: var(--s5);
}

.gate__pins {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  margin-bottom: var(--s4);
}
.gate__group { display: flex; gap: var(--s2); }

.gate__pin-leaf {
  position: relative;
  width: 35px;
  height: 35px;
  flex-shrink: 0;
}
.gate__pin-leaf::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.70);
  border: 1.5px solid rgba(0,0,0,0.12);
  transition: border-color .18s, background .18s, box-shadow .18s, transform .15s;
  pointer-events: none;
}
.gate__pin-leaf::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.2s cubic-bezier(0.34, 1.5, 0.64, 1);
  pointer-events: none;
  z-index: 2;
}
.gate__pin-leaf:focus-within::before {
  border-color: var(--accent);
  background: rgba(255,255,255,0.96);
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(139,94,60,0.18);
}
.gate__pin-leaf.is-filled::before {
  border-color: var(--accent);
  background: rgba(139,94,60,0.10);
}
.gate__pin-leaf.is-filled::after  { transform: translate(-50%, -50%) scale(1); }
.gate__pin-leaf.is-error::before  { border-color: #D94F4F; background: rgba(217,79,79,0.07); box-shadow: 0 0 0 3px rgba(217,79,79,0.12); }
.gate__pin-leaf.is-error::after   { background: #D94F4F; transform: translate(-50%, -50%) scale(1); }
.gate__pin-leaf.is-success::before{ border-color: #C8922A; background: rgba(200,146,42,0.12); box-shadow: 0 0 0 3px rgba(200,146,42,0.22); transform: scale(1.08); }
.gate__pin-leaf.is-success::after { background: #C8922A; transform: translate(-50%, -50%) scale(1); }

.gate__pin {
  position: absolute;
  inset: 0;
  background: transparent;
  border: none;
  outline: none;
  color: transparent !important;
  text-shadow: none !important;
  caret-color: transparent;
  z-index: 1;
  opacity: 0;
}

.gate__from {
  font-size: 12px;
  color: var(--c-faint);
  letter-spacing: 0.12em;
  margin-top: var(--s4);
}

@keyframes card-shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-9px); }
  40%,80% { transform: translateX(9px); }
}
.gate__card.is-shaking { animation: card-shake 0.4s ease; }

@media (max-width: 500px) {
  .gate__card     { padding: 36px 20px 28px; }
  .gate__pin-leaf { width: 36px; height: 36px; }
}

/* ═══════════════════════════════════════
   Responsive
═══════════════════════════════════════ */
@media (max-width: 640px) {
  .k-phrase {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
  }
  .k-phrase__jp    { grid-column: 1 / -1; }
  .k-phrase__std   { grid-column: 1; grid-row: 2; }
  .k-phrase__busan { grid-column: 2; grid-row: 2; }
  .k-phrase__read-std  { grid-column: 1; grid-row: 3; }
  .k-phrase__read-busan { grid-column: 2; grid-row: 3; }
}
