/* Components — reusable UI pieces
   Header, footer, alerts, etc. */

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--sp-6) 0;
  background: var(--paper);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-header.is-hidden {
  transform: translateY(-100%);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  font-weight: 200;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  border-bottom: none;
}

.site-title:hover {
  border-bottom: none;
}

.site-header nav {
  display: flex;
  gap: var(--sp-7);
}

.site-header nav a {
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--grey-3);
  border-bottom: none;
}

.site-header nav a:hover {
  color: var(--ink);
  border-bottom: none;
}

/* Sections */
.section {
  padding: var(--sp-10) 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--ink);
  padding-bottom: var(--sp-5);
  margin-bottom: var(--sp-8);
}

.section-header h2 {
  font-weight: 200;
}

.section-header .t-meta {
  flex-shrink: 0;
}

.comment-count {
  font-size: 0.5em;
  font-weight: 400;
  color: var(--grey-3);
  margin-left: 0.5em;
  vertical-align: baseline;
}

/* About section */
.about-content {
  width: 100%;
}

.about-text {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--grey-3);
}

/* Guestbook intro — tighten vertical spacing */
.section-intro {
  padding-bottom: var(--sp-5);
}

.section-intro .about-content {
  margin: 0 auto;
  padding-top: 0;
}

.section-intro .about-text {
  margin: 0;
}

/* Comments (guestbook) — tighten gap to the intro text */
.section-comments {
  padding-top: 0;
  max-width: 90ch;
  margin: 0 auto;
}

/* Hide the remote comment widget's own "评论" heading — page already has one */
.lc-title {
  display: none !important;
}

/* Sort dropdown — relocated below the comment form, above the list */
#dwx-comment .lc-sort {
  margin: 0 0 var(--sp-4);
}

/* 留言组件（远程样式，不受本项目控制）——移动端防横向溢出 */
#dwx-comment {
  min-width: 0;
  overflow-wrap: break-word;
}
#dwx-comment img {
  max-width: 100%;
  height: auto;
}
#dwx-comment pre,
#dwx-comment code {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Contact grid */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-5);
}

.contact-item {
  padding: var(--sp-5) 0;
  border-bottom: 1px solid var(--grey-2);
}

.contact-label {
  display: block;
  margin-bottom: var(--sp-3);
}

.contact-value {
  font-size: 1rem;
  font-weight: 400;
}

.contact-copy {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
}

.contact-copy::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.5;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.contact-copy:hover::after {
  opacity: 1;
}

.contact-copy.copied::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  opacity: 1;
}

/* GitHub Alerts */
.markdown-alert {
  border-left: 3px solid var(--grey-2);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-7);
  background: var(--grey-1);
}

.markdown-alert p {
  margin-bottom: 0;
  max-width: none;
}

.markdown-alert-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-3);
  color: var(--ink);
}

.markdown-alert-title svg {
  flex-shrink: 0;
  fill: currentColor;
}

/* Tier 1: informational */
.markdown-alert-note,
.markdown-alert-tip {
  border-left-color: var(--grey-3);
}

/* Tier 2: action required */
.markdown-alert-important,
.markdown-alert-warning,
.markdown-alert-caution {
  border-left-color: var(--ink);
  border-left-width: 4px;
}

/* Footer — masthead / colophon style */
.site-footer {
  padding: var(--sp-10) 0 var(--sp-8);
  margin-top: var(--sp-10);
}

.footer-masthead {
  border-top: 2px solid var(--ink);
  padding-top: var(--sp-6);
}

.footer-masthead-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-7);
  align-items: center;
  margin-bottom: var(--sp-9);
}

.footer-domain {
  font-family: var(--sans-display);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 200;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
  border-bottom: none;
}

.footer-domain:hover {
  color: var(--grey-3);
  border-bottom: none;
}

.footer-tagline {
  font-size: 0.85rem;
  font-weight: 300;
  line-height: 1.6;
  color: var(--grey-3);
  max-width: 36ch;
  margin: 0;
  justify-self: end;
  text-align: right;
}

.footer-masthead-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  padding-top: var(--sp-5);
}

.footer-meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--grey-2-5);
  margin: 0;
}

.footer-meta-sep {
  margin: 0 var(--sp-3);
  color: var(--grey-2);
}

.footer-link {
  color: var(--grey-2-5);
  border-bottom: 1px solid var(--grey-1-5);
  transition: color 0.2s, border-color 0.2s;
}

.footer-link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

@media (max-width: 768px) {
  .footer-masthead-top {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
    margin-bottom: var(--sp-7);
  }

  .footer-tagline {
    justify-self: start;
    text-align: left;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .site-header nav {
    gap: var(--sp-5);
  }
}

/* Mobile — 小屏手机：压缩 header，避免标题与导航溢出 */
@media (max-width: 480px) {
  .site-title {
    font-size: 1.15rem;
  }

  .site-header nav {
    gap: var(--sp-4);
  }

  .site-header nav a {
    font-size: 0.7rem;
  }

  .footer-meta {
    font-size: 0.65rem;
  }
}

/* Touch devices — 加大点击区域（触屏设备才生效，不影响桌面 hover 布局） */
@media (hover: none) {
  .site-header nav a,
  .contact-copy,
  .footer-link {
    padding: 6px 0;
  }
}

/* iOS safe areas — header 避开刘海/状态栏，footer 避开底部横条 */
@supports (padding-top: env(safe-area-inset-top)) {
  .site-header {
    padding-top: max(var(--sp-6), env(safe-area-inset-top));
  }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .site-footer {
    padding-bottom: max(var(--sp-8), env(safe-area-inset-bottom));
  }
}

