/* Mobile-only composition. Desktop styles stay in style.css. */
.social-icon, .info-icon { border: 0; padding: 0; }
.mobile-profile-img { display: none; }

.online-id-copy {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-inline-start: 8px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-sub);
  vertical-align: middle;
  cursor: pointer;
  transition: transform 160ms ease-out;
}
.online-id-copy:active { transform: scale(.9); }
.online-id-copy:hover, .online-id-copy:focus-visible {
  background: var(--surface-hover);
}
.online-id-copy::before, .online-id-copy::after {
  content: '';
  grid-area: 1 / 1;
  width: 8px;
  height: 10px;
  border: 1px solid currentColor;
  border-radius: 2px;
}
.online-id-copy::before { transform: translate(-2px, -2px); }
.online-id-copy::after {
  background: var(--surface);
  transform: translate(2px, 2px);
}
.online-id-copy.copied::before { display: none; }
.online-id-copy.copied::after {
  width: auto;
  height: auto;
  border: 0;
  background: transparent;
  transform: none;
  content: '✓';
  color: var(--green);
  animation: online-id-check-in 340ms cubic-bezier(.2,.75,.3,1) both;
}

@keyframes online-id-check-in {
  0% { opacity: 0; transform: scale(.55) rotate(-16deg); }
  65% { opacity: 1; transform: scale(1.24) rotate(4deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

.online-id-copy-status {
  display: inline-block;
  margin-inline-start: 6px;
  font-size: .75rem;
}
.online-id-copy-status:not(:empty) {
  animation: online-id-status-in 300ms cubic-bezier(.22,1,.36,1) both;
}
@keyframes online-id-status-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
.online-id-copy-status.is-fading:not(:empty) {
  animation: online-id-status-out 220ms ease-in both;
}
@keyframes online-id-status-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .online-id-copy { transition: none; }
  .online-id-copy:active { transform: none; }
  .online-id-copy.copied::after,
  .online-id-copy-status:not(:empty),
  .online-id-copy-status.is-fading:not(:empty) { animation: none; }
}

body.animations-off .online-id-copy:active { transform: none; }
body.mobile-view .online-id-copy { width: 44px; height: 44px; }

.section-toc {
  --toc-label-width: min(260px, calc(100vw - 42px));
  position: fixed;
  top: 50%;
  right: max(10px, env(safe-area-inset-right, 0px));
  z-index: 910;
  transform: translateY(-50%);
  color: var(--text);
}

/* Keep the pointer inside the TOC across the row gaps and during the reveal. */
.section-toc.is-open {
  width: calc(var(--toc-label-width) + 8px);
}

.section-toc ul {
  display: grid;
  justify-items: end;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.section-toc button {
  position: relative;
  display: block;
  width: 44px;
  height: clamp(44px, 10dvh, 80px);
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.section-toc button::after {
  content: '';
  position: absolute;
  inset: 4px 4px 4px auto;
  width: 4px;
  border-radius: 999px;
  background: var(--green);
}

.section-toc-label {
  position: absolute;
  inset: 0 8px 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  box-sizing: border-box;
  width: var(--toc-label-width);
  padding: 6px 18px;
  border: 1px solid var(--border);
  border-radius: 12px 0 0 12px;
  background: var(--surface);
  font-size: clamp(1rem, 2.4vw, 1.3rem);
  font-weight: 600;
  text-align: right;
  opacity: 0;
  clip-path: inset(0 0 0 100%);
  transform: translateX(8px);
  pointer-events: none;
  transition: clip-path 380ms cubic-bezier(.22,1,.36,1),
    transform 380ms cubic-bezier(.22,1,.36,1), opacity 280ms ease;
}

.section-toc-label::after {
  content: '';
  position: absolute;
  inset: auto 18px 8px;
  height: 1px;
  background: var(--text-muted);
  opacity: .45;
}

.section-toc li:nth-child(2) { --toc-delay: 45ms; }
.section-toc li:nth-child(3) { --toc-delay: 90ms; }
.section-toc li:nth-child(n+4) { --toc-delay: 135ms; }

.section-toc.is-open .section-toc-label,
.section-toc:has(:focus-visible) .section-toc-label {
  opacity: 1;
  clip-path: inset(0);
  transform: translateX(0);
  transition-delay: var(--toc-delay, 0ms);
  pointer-events: auto;
}

.section-toc button:hover .section-toc-label,
.section-toc button:focus-visible .section-toc-label {
  background: var(--surface-hover);
}

#bio .bio-right > h2, #core .content-body > h2 { scroll-margin-top: 72px; }
body.modal-open .section-toc { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .section-toc-label { transition: none; }
}

/* This preference applies to desktop and mobile, including CSS-only effects. */
body.animations-off *,
body.animations-off *::before,
body.animations-off *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
body.animations-off .hello-anim,
body.animations-off .write-anim {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  clip-path: none !important;
}
body.animations-off .cursor { display: none !important; }

/* Two full-screen diagonal strokes reveal the desktop page in sequence. */
.desktop-tab-sweep {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 850;
}
.desktop-tab-sweep-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 250vmax;
  height: 4px;
  border-radius: 999px;
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--green) 30%, var(--blue) 70%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--blue) 45%, transparent);
  will-change: transform, opacity;
}
.desktop-tab-sweep-line + .desktop-tab-sweep-line { height: 2px; }
body.mobile-view .desktop-tab-sweep { display: none; }

body.mobile-view {
  --mobile-nav-height: 72px;
  --mobile-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  min-height: 100dvh;
  margin: 0;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) calc(var(--mobile-bottom) + 152px) max(20px, env(safe-area-inset-left, 0px));
  -webkit-text-size-adjust: 100%;
  line-height: 1.8;
}

body.mobile-view #main {
  display: block;
  max-width: 640px;
  margin-inline: auto;
  padding: 0;
  min-width: 0;
}

body.mobile-view .tab-content.active {
  display: block;
  position: relative;
  min-width: 0;
}

body.mobile-view h1 {
  position: absolute;
  top: 2px;
  right: 0;
  z-index: 0;
  pointer-events: none;
  writing-mode: vertical-rl;
  transform: none;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: clamp(3rem, 12vw, 4.25rem);
  font-weight: 300;
  line-height: 1.35;
  letter-spacing: .12em;
  opacity: .3;
}

body.mobile-view .content-body,
body.mobile-view .bio-content-body,
body.mobile-view .bio-right {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  border: 0;
  overflow-wrap: anywhere;
}

body.mobile-view .content-body,
body.mobile-view .bio-content-body { position: relative; z-index: 1; padding-top: 16px; }

/* Blur only the background behind content, leaving the foreground text sharp. */
body.mobile-view :is(.content-body, .bio-right) > :is(p:not(.content-spacer), h2, h4, .setting-item, .profile-section, .archive-link, .archive-browser),
body.mobile-view .gallery-item {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

body.mobile-view h2 {
  margin: 32px 0 18px;
  font-size: 1.45rem;
  line-height: 1.7;
}

body.mobile-view .content-body > h2:first-child,
body.mobile-view .bio-right > h2:first-child {
  margin-top: 0;
}

body.mobile-view p { margin: 0 0 14px; }
body.mobile-view :is(.content-body, .bio-right) > :is(p, h2, h4) { width: fit-content; max-width: 100%; }
body.mobile-view .content-spacer { display: none; }
body.mobile-view .mobile-development-note { display: none; }
body.mobile-view h4 { margin: 24px 0 14px; line-height: 1.7; }
body.mobile-view hr { margin: 20px 0; }
body.mobile-view .bio-left { display: none; }
body.mobile-view .mobile-profile-img {
  display: block;
  position: relative;
  z-index: 1;
  width: 104px;
  height: 104px;
  margin: 8px 0 20px;
  border-radius: 50%;
  object-fit: cover;
}
body.mobile-view .profile2-img { display: block; max-width: 100%; margin: 24px auto; }
body.mobile-view .translation-notice {
  margin: 0 auto 24px;
  max-width: 640px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .75rem;
  line-height: 1.7;
}

body.mobile-view nav {
  position: fixed;
  inset: auto 0 0;
  box-sizing: border-box;
  width: 100%;
  padding: 0 max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  z-index: 900;
}

body.mobile-view .nav-wrapper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
}

body.mobile-view .tab-btn {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: var(--mobile-nav-height);
  padding: 10px 4px;
  border-radius: 0;
  font-family: 'Kiwi Maru', serif;
  font-size: 11px;
  font-style: normal;
  line-height: 1.4;
  cursor: pointer;
}

body.mobile-view .tab-btn img {
  display: block !important;
  width: 24px !important;
  height: 24px !important;
  border-radius: 0 !important;
  object-fit: contain !important;
}

body.mobile-view .tab-btn span { display: block; }
body.mobile-view .tab-btn.active { color: var(--green); background: transparent; }
body.mobile-view .tab-line { bottom: auto; top: 0; }

body.mobile-view button:focus-visible,
body.mobile-view a:focus-visible,
body.mobile-view summary:focus-visible,
body.mobile-view [role="button"]:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

body.mobile-view .gallery-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  min-width: 0;
  background: transparent;
  border-radius: 0;
}

body.mobile-view .gallery-item { min-width: 0; aspect-ratio: 4 / 3; }
body.mobile-view .gallery-item img { display: block; width: 100%; height: 100%; }
body.mobile-view .gallery-section { margin-bottom: 32px; }
body.mobile-view #gallery .content-body > h2 { margin: 32px 0 18px; }
body.mobile-view #gallery .content-body > h2:first-child { margin-top: 0; }
body.mobile-view .gallery-overlay { padding: 10px; }
body.mobile-view .gallery-info strong { font-size: .85rem; }
body.mobile-view .gallery-more-btn { min-height: 44px; }

body.mobile-view .setting-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
body.mobile-view .setting-item > span { font-size: .9rem; line-height: 1.7; }
body.mobile-view .setting-select-button { min-width: 124px; max-width: 100%; }
body.mobile-view .setting-toggle,
body.mobile-view .setting-select-button,
body.mobile-view .setting-option { min-height: 44px; }
body.mobile-view .setting-select-menu { min-width: 164px; max-width: 100%; }
/* Lift the whole animated menu above adjacent rows' backdrop filters. */
body.mobile-view .custom-select.is-open { z-index: 110; }
body.mobile-view .archive-link { box-sizing: border-box; max-width: 100%; min-height: 44px; margin: 4px 0 12px; line-height: 1.8; }
body.mobile-view .archive-root,
body.mobile-view .archive-folder,
body.mobile-view .archive-file { box-sizing: border-box; max-width: 100%; min-height: 44px; }
body.mobile-view .archive-viewer { min-width: 0; max-width: 100%; }
body.mobile-view .archive-code { max-width: 100%; overflow-x: auto; white-space: pre; }
body.mobile-view .profile-section { box-sizing: border-box; margin: 24px 0; }
body.mobile-view .profile-section summary { min-height: 48px; }
body.mobile-view .favorite > div { min-width: 0; }
.favorite-number {
  flex: 0 0 auto;
  min-width: 2ch;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  font-variant-numeric: tabular-nums;
}
body.mobile-view .rank { flex-shrink: 0; }

body.mobile-view .social-btn {
  bottom: calc(var(--mobile-bottom) + 16px);
  right: max(20px, env(safe-area-inset-right, 0px));
}
body.mobile-view .social-icon { width: 48px; height: 48px; }
body.mobile-view .social-link { min-height: 44px; }
body.mobile-view .info-btn {
  right: max(22px, env(safe-area-inset-right, 0px)) !important;
  bottom: calc(var(--mobile-bottom) + 80px) !important;
  width: 44px;
  height: 44px;
}
body.mobile-view .info-tooltip {
  box-sizing: border-box;
  width: min(320px, calc(100vw - 44px));
  max-height: calc(100dvh - var(--mobile-bottom) - 160px);
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
}

body.mobile-view.modal-open { overflow: hidden; }
body.mobile-view #modal { height: 100dvh; overflow: hidden; z-index: 2000; }
body.mobile-view #modal-img { width: 88vw; height: 70dvh; }
body.mobile-view #modal-info {
  box-sizing: border-box;
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  max-width: none;
  max-height: 28dvh;
  overflow-y: auto;
  padding: 12px 14px;
  line-height: 1.7;
}
body.mobile-view #modal-info span { font-size: .8rem; }
body.mobile-view #modal-controls {
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
body.mobile-view #modal-controls button { min-height: 44px; }
body.mobile-view #modal-close { position: static; font-size: 1.3rem; }

@media (max-width: 359px) {
  body.mobile-view { padding-inline: 16px; }
  body.mobile-view .gallery-grid { grid-template-columns: minmax(0, 1fr); }
  body.mobile-view .setting-item { grid-template-columns: minmax(0, 1fr); }
  body.mobile-view .setting-item > button { justify-self: start; }
  body.mobile-view .setting-select-menu { right: auto; left: 0; }
}
