/*
 * DesertRose Blog 셸 스타일.
 * SUBSITE SHELL CONTRACT 2.0.0
 *
 * 원래 SiteTemplate에서 복사해 오던 공용 셸이었지만, 블로그를 desertrose.gizmogames.dev로 독립시키면서
 * 다른 사이트와의 연결(SITES 메뉴)을 끊고 이 레포에서 직접 관리합니다.
 *
 * 헤더, 공용 컨트롤, 푸터 UI는 이 파일이, 본문 디자인은 style.css가 담당합니다.
 *
 * 색상 토큰(--paper / --ink / --muted / --line / --red / --blue / --acid)은 각 사이트의 style.css가
 * 정의하고, 이 파일은 그 토큰만 사용합니다. 그래서 이 파일은 항상 style.css **뒤에** 불러야 합니다.
 */

:root {
  --sub-font-sans: Arial, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --sub-font-mono: Consolas, "Cascadia Code", "SFMono-Regular", "Courier New", monospace;
  --sub-shell-width: 1240px;
  --sub-shell-gutter: 56px;
  --sub-control-height: 40px;
  --sub-brand-size: 40px;
}

body[data-site-id] {
  font-family: var(--sub-font-sans);
}

/* 헤더 로고 배경색만 사이트별로 다릅니다. */
body[data-site-id="blog"],
body[data-site-id="study"] {
  --sub-shell-accent: var(--red);
}

body[data-site-id="micro3d"] {
  --sub-shell-accent: var(--berry);
}

body[data-site-id="template"] {
  --sub-shell-accent: #171716;
}

/* ---------- 공용 유틸리티 ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.container {
  width: min(var(--sub-shell-width), calc(100% - var(--sub-shell-gutter)));
  min-height: 72vh;
  margin-inline: auto;
  padding: 28px 0 120px;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font: 700 .68rem var(--sub-font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.signal-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  display: inline-block;
  border: 1px solid #111;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--acid) 18%, transparent);
}

.reading-progress {
  position: fixed;
  z-index: 1000;
  inset: 0 auto auto 0;
  width: 0;
  height: 4px;
  background: var(--red);
}

.primary-button,
.ghost-button {
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  font: 700 .66rem var(--sub-font-mono);
  transition: color .15s, background .15s;
}

.primary-button {
  color: var(--paper);
  background: var(--ink);
}

.ghost-button {
  background: transparent;
}

.primary-button:hover,
.primary-button:focus-visible {
  color: #111;
  background: var(--acid);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  color: #fff;
  background: var(--blue);
}

.toast {
  position: fixed;
  z-index: 500;
  left: 50%;
  bottom: 24px;
  padding: 9px 14px;
  color: #111;
  background: var(--acid);
  border: 1px solid #111;
  font: 700 .64rem var(--sub-font-mono);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 마스트헤드 ---------- */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--ink);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(12px);
}

.nav-container {
  width: min(var(--sub-shell-width), calc(100% - var(--sub-shell-gutter)));
  min-height: 76px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: var(--sub-brand-size);
  height: var(--sub-brand-size);
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--sub-shell-accent);
  border: 1px solid #111;
  border-radius: 50%;
  font: 900 .66rem var(--sub-font-sans);
  transform: rotate(-8deg);
}

.brand-copy {
  font: 900 .7rem/.88 var(--sub-font-sans);
  letter-spacing: -.03em;
}

.issue-label {
  padding-left: 22px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  font: .62rem var(--sub-font-mono);
  letter-spacing: .1em;
}

/* 컨트롤 순서는 사이트 고유 동작 → SEARCH → LANGUAGE → THEME 입니다. */
.nav-actions {
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-button,
.icon-button,
.language-select,
.search-box input {
  height: var(--sub-control-height);
  min-height: var(--sub-control-height);
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  font: 700 .64rem var(--sub-font-mono);
  transition: color .15s, background .15s;
}

.nav-button {
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.icon-button {
  width: var(--sub-control-height);
  padding: 0;
  font-size: 1rem;
}

.language-select {
  min-width: 74px;
  padding: 0 24px 0 9px;
  cursor: pointer;
}

.language-select option {
  color: var(--ink);
  background: var(--paper);
}

.nav-button kbd,
.search-box kbd {
  padding: 1px 5px;
  color: var(--muted);
  border: 1px solid var(--line);
  font: .62rem var(--sub-font-mono);
}

.nav-button:hover,
.nav-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible,
.language-select:hover,
.language-select:focus-visible {
  color: var(--paper);
  background: var(--ink);
  outline: none;
}

/* 끄기 상태의 토글은 눌린 상태처럼 보이지 않도록 흐리게 둡니다. */
.icon-button[aria-pressed="false"] {
  color: var(--muted);
  border-color: var(--line);
}

.search-box {
  position: relative;
}

.search-box input {
  width: 210px;
  padding: 0 39px 0 12px;
  outline: 0;
  font-weight: 400;
  letter-spacing: .04em;
  transition: width .15s;
}

.search-box input:focus {
  width: 280px;
  box-shadow: inset 4px 0 var(--blue);
}

.search-box kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

/* ---------- 푸터 ---------- */

.site-footer {
  border-top: 1px solid var(--ink);
}

.footer-inner {
  width: min(var(--sub-shell-width), calc(100% - var(--sub-shell-gutter)));
  min-height: 140px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  color: var(--muted);
  font: .64rem/1.7 var(--sub-font-mono);
}

.footer-inner p {
  margin: 0;
}

.footer-inner strong,
.footer-inner a {
  color: var(--ink);
}

.footer-inner a {
  font-weight: 700;
}

.footer-inner a:hover {
  color: var(--red);
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

@media (max-width: 680px) {
  .container,
  .nav-container,
  .footer-inner {
    width: calc(100% - 28px);
  }

  .nav-container {
    min-height: 68px;
    gap: 10px;
  }

  .issue-label,
  .brand-copy {
    display: none;
  }

  .brand-mark {
    --sub-brand-size: 36px;
  }

  .nav-actions {
    width: auto;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .nav-button,
  .icon-button,
  .language-select,
  .search-box input {
    height: 38px;
    min-height: 38px;
  }

  .icon-button {
    width: 38px;
  }

  .nav-button {
    padding-inline: 11px;
  }

  /* 좁은 화면에서는 사이트 고유 동작 버튼을 접고 검색과 언어만 남깁니다. */
  body[data-site-id="blog"] #randomPost,
  body[data-site-id="template"] .template-action {
    display: none;
  }

  body[data-site-id="blog"] .search-box input,
  body[data-site-id="blog"] .search-box input:focus {
    width: 86px;
    padding-right: 30px;
  }

  .language-select {
    width: 66px;
    min-width: 66px;
    padding-left: 7px;
  }


  .footer-inner {
    min-height: 190px;
    gap: 10px;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  body[data-site-id="blog"] .search-box input,
  body[data-site-id="blog"] .search-box input:focus {
    width: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
