/* --- header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 2rem 0.9rem 4.5rem; /* 左上の固定トグルボタン分を確保 */
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-line);
}

.site-header__brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.site-header__name {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
  font-size: 1rem;
  color: var(--color-text);
  letter-spacing: 0.03em;
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-header__name:hover,
.site-header__name:focus-visible {
  color: var(--color-matcha);
}

.site-header__social {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.social-link {
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  margin: -0.35rem;
  border-radius: 4px;
  transition: color 0.2s ease;
  touch-action: manipulation;
}

.social-link:hover,
.social-link:focus-visible {
  color: var(--color-matcha);
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.site-header__nav a {
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.site-header__nav a:hover,
.site-header__nav a:focus-visible {
  color: var(--color-matcha);
}

/* タブレット・スマホ対応：820px以下ではナビゲーションリンクを非表示にしてトグルボタン/サイドバーに集約 */
@media (max-width: 820px) {
  .site-header {
    padding: 0.75rem 1rem 0.75rem 3.8rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  .site-header__nav {
    display: none;
  }
}

/* --- layout --- */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 2rem;
  position: relative;
}

@media (max-width: 600px) {
  main {
    padding: 0 1.1rem;
  }
}

section {
  padding: var(--space-section) 0;
  position: relative;
  isolation: isolate;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  margin: 0 0 2.5rem;
  letter-spacing: 0.03em;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-line);
}

/* --- footer --- */
.site-footer {
  border-top: 1px solid var(--color-line);
  padding: 1.25rem 2rem;
  margin-top: 0;
}

.site-footer__inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem 1.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__nav a {
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  transition: color 0.2s ease;
}

.site-footer__nav a:hover,
.site-footer__nav a:focus-visible {
  color: var(--color-matcha);
}

.site-footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-line);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-footer__name {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-footer__name:hover,
.site-footer__name:focus-visible {
  color: var(--color-matcha);
}

.site-footer__copy {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0;
  font-family: var(--font-mono);
}

.section-placeholder {
  color: var(--color-matcha);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* --- infinite math background layer (Infinite Golden Scale Conformal Ring) --- */
.infinite-math-bg {
  position: absolute;
  top: -180px;
  right: -380px;
  width: min(1100px, 120vw);
  height: min(1100px, 120vw);
  pointer-events: none;
  z-index: -2;
  overflow: visible;
}

.infinite-math-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.infinite-ring-path {
  fill: none;
  stroke: var(--color-matcha);
  stroke-width: var(--ring-sw, 0.5px);
  opacity: calc(var(--ring-op, 0.3) * 0.45);
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.infinite-ray-path {
  fill: none;
  stroke: var(--color-matcha-light);
  stroke-width: 0.45px;
  opacity: 0.12;
  stroke-dasharray: 2 4;
  vector-effect: non-scaling-stroke;
}

@media (max-width: 600px) {
  .infinite-math-bg {
    top: -50px;
    right: -100px;
    width: min(420px, 95vw);
    height: min(420px, 95vw);
    opacity: 0.6;
  }
}

/* --- level 2 micro scale recursive card accents --- */
.card-math-accent {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 90px;
  height: 90px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.16;
  transition: opacity 0.3s ease;
}

.works__item-body:hover .card-math-accent,
.skill-card:hover .card-math-accent,
.contact-form:focus-within .card-math-accent {
  opacity: 0.38;
}

.card-math-path {
  fill: none;
  stroke: var(--color-matcha);
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.card-math-path--0 { opacity: 0.4; stroke-width: 0.65px; }
.card-math-path--1 { opacity: 0.65; stroke-width: 0.55px; }
.card-math-path--2 { opacity: 0.85; stroke-width: 0.5px; }