@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

/* ==============================
   Design tokens
   ============================== */
:root {
  --primary-color: #000000;
  --primary-dark: #222222;
  --bg-color: #ffffff;
  --text-color: #000000;
  --gray: #555555;
  --border: #cccccc;
  --card-bg: #ffffff;
  --shadow: rgba(0,0,0,0.08);
  --shadow-hover: rgba(0,0,0,0.12);
}

/* ==============================
   Reset / Base
   ============================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  margin: 0;
  padding-top: 80px;                /* fixed nav 보정 */
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text-color);
  background: var(--bg-color);
  line-height: 1.6;
}

/* ==============================
   Header / Nav
   ============================== */
header { background: #fff; }

nav {
  position: fixed; top: 0; left: 0; right: 0;
  width: 100%;
  z-index: 9999;
  background-color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Logo (링크 포함 통일) */
.logo, .logo a {
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.5px;
  color: var(--primary-color);
  text-decoration: none;
}

/* Nav list (Desktop default: 보임) */
nav ul {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

nav li { display: block; }

nav a {
  position: relative;
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
  padding-bottom: 4px;
}

/* 하이라이트/언더라인 애니메이션 */
nav a::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 0%;
  height: 2px;
  background-color: var(--primary-color);
  transition: width .25s ease;
}
nav a:hover::after,
nav a:focus::after { width: 100%; }

/* 햄버거 아이콘 */
.menu-toggle {
  display: none;            /* Desktop 숨김, 모바일에서 노출 */
  flex-direction: column;
  cursor: pointer;
  gap: 5px;
  padding: 8px;
  user-select: none;
}
.menu-toggle div {
  width: 28px; height: 3px;
  background-color: #000;   /* 강제 블랙 */
  transition: .3s;
}

/* ==============================
   Main / Content
   ============================== */
main {
  max-width: 900px;
  margin: 5rem auto;
  padding: 0 1.5rem;
}

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: left;
}
.content h1, .content h2, .content h3,
.content p, .content ul, .content ol, .content li {
  text-align: left;
  margin-left: 0; padding-left: 0;
}

/* ==============================
   Tool section (도구 페이지 공통)
   ============================== */
section.tool {
  background: linear-gradient(to bottom, #ffffff, #f9fafb);
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: 0 8px 24px var(--shadow);
}
section.tool h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
  text-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.tool-description {
  max-width: 700px;
  margin: 0 auto 1.5rem;
  color: var(--gray);
  font-size: 1rem;
  line-height: 1.5;
  text-align: center;
}

/* Textareas */
section.tool textarea {
  width: 100%;
  height: 300px;
  margin: 0 0 1.5rem;
  padding: 1.25rem;
  font-size: 1.05rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  resize: vertical;
  background-color: #fff;
  color: var(--text-color);
}
section.tool textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}
section.tool textarea::placeholder {
  color: #9ca3af;
  font-style: italic;
}

/* Buttons */
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
button {
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  padding: .8rem 1.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 1rem;
  display: flex; align-items: center; gap: .5rem;
  user-select: none;
  transition: transform .15s ease, background-color .2s ease;
}
button:hover { background-color: var(--primary-dark); transform: translateY(-2px); }
button:active { transform: scale(0.97); }
button.encode::before { content: "🔐"; }
button.decode::before { content: "🔓"; }
button.copy::before   { content: "📋"; }
button.download::before { content: "⬇️"; }
button.clear::before  { content: "❌"; }

/* Status message */
.status {
  margin: .5rem 0;
  font-weight: 500;
  color: green;
  min-height: 1.5rem;
}

/* Generic sections */
section { margin-top: 5rem; scroll-margin-top: 100px; }
section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
  text-align: center;
  font-weight: 600;
  letter-spacing: -0.3px;
}
section p {
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  color: var(--gray);
  font-size: 1rem;
  line-height: 1.6;
}

/* About / Terms / Contact 배경 */
section#about, section#terms, section#contact {
  background-color: #f9fafb;
  border-radius: 12px;
  padding: 2rem 1.5rem;
  margin-bottom: 3rem;
}

/* ==============================
   Footer
   ============================== */
footer {
  text-align: center;
  padding: 2rem;
  font-size: .9rem;
  background-color: #f1f5f9;
  color: var(--gray);
  margin-top: 6rem;
  user-select: none;
}

/* ==============================
   Animations
   ============================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==============================
   Responsive
   ============================== */

/* 모바일: 햄버거 노출, 목록 기본 숨김 */
@media (max-width: 768px) {
  nav { flex-wrap: wrap; justify-content: space-between; }

  .logo, .logo a { font-size: 1.5rem; }

  .menu-toggle { display: flex !important; }

  /* 드롭다운 메뉴 */
  nav ul {
    display: none;                 /* 기본 숨김 */
    position: absolute;
    top: 60px; right: 16px;
    background-color: #ffffff;
    flex-direction: column;
    width: 220px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
    z-index: 1000;
    gap: 0;
  }
  nav ul.show { display: flex; }   /* 토글 시 표시 */

  nav ul li {
    border-bottom: 1px solid #e0e0e0;
    padding: 12px 16px;
    text-align: left;
    background-color: #ffffff;
  }
  nav ul li:last-child { border-bottom: none; }

  nav a { font-size: 1rem; }

  section.tool { padding: 2rem 1rem; }
  .buttons { flex-direction: column; }
  button { width: 100%; }
}

/* 더 작은 화면에서 타이포 축소 */
@media (max-width: 480px) {
  .logo, .logo a { font-size: 1.35rem; }
  nav { padding: 12px 20px; }
}

/* --- ensure hamburger is visible on mobile (must be last) --- */
@media (max-width: 768px) {
  nav .menu-toggle { display: flex !important; }
  nav ul { display: none; }
  nav ul.show { display: flex; }
}

/* ===== 모바일 좌우 스크롤 방지 (페이지 전체는 고정, 내부 요소만 스크롤) ===== */

/* 안전장치: 페이지 자체의 가로 오버플로우 차단 */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* 본문에서 긴 단어/URL도 강제로 줄바꿈 허용 */
.content p,
.content li,
.content h1,
.content h2,
.content h3,
.content code {
  overflow-wrap: anywhere;   /* 긴 토큰도 줄바꿈 */
  word-break: break-word;    /* 구형 브라우저 보조 */
}

/* 코드 블록은 페이지를 밀지 말고, 블록 내부에서만 가로 스크롤 */
.content pre {
  max-width: 100%;
  overflow-x: auto;              /* 내부 가로 스크롤 */
  -webkit-overflow-scrolling: touch;
  white-space: pre;              /* 코드 정렬 유지 */
  box-sizing: border-box;
  padding-bottom: 8px;           /* 모바일에서 스크롤바 여유 */
  border-radius: 8px;            /* (기존 톤 유지) */
}

/* pre 안의 code가 강제로 한 줄로 늘어나는 것 방지(브라우저별 안정화) */
.content pre code {
  display: inline-block;
  min-width: 100%;
}

/* 인라인 코드가 너무 길 때 줄바꿈 허용 (제목/문단 속 긴 URL 대비) */
.content :not(pre) > code {
  white-space: normal;
}

/* 이미지/표가 컨테이너를 넘지 않게 */
.content img,
.content table {
  max-width: 100%;
  height: auto;
}

/* 표가 넓을 때 표 영역 내부에서만 가로 스크롤 */
.content table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 네비게이션 메뉴가 의도치 않게 가로를 밀어내지 않도록(안전장치) */
nav ul {
  max-width: 100%;
}

