/* ============================================================
   Personal homepage: hero + merged feed
   Injected on every page via inject.head in _config.butterfly.yml,
   but the selectors only match on the index page.
   ============================================================ */

/* ---------- hero ---------- */
#home-hero {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#home-hero-slides {
  position: absolute;
  inset: 0;
}

.home-hero-slide {
  position: absolute;
  inset: 0;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.4s ease-in-out;
}

/* first slide is a permanent base layer so the hero never goes blank */
.home-hero-slide:first-child { opacity: 1; }
.home-hero-slide.is-active { opacity: 1; }

/* darken whatever photo is showing so the text stays readable */
#home-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, .38);
  pointer-events: none;
}

#home-hero-inner {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 60px;
  text-align: center;
}

#home-hero-avatar {
  /* A flex item only shrinks along the main axis. In this column container that
     means short viewports squeeze the height while the width stays put, which
     flattens the circle into a very wide ellipse. Keeping the item at its own
     size (`flex: 0 0 auto`) and forcing a 1:1 aspect ratio makes it impossible
     to distort, while the responsive width below still lets it get smaller. */
  flex: 0 0 auto;
  width: clamp(56px, min(17vh, 44vw), 126px);
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, .85);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  background: rgba(255, 255, 255, .2);
}

#home-hero-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* The name must stay exactly centred on the page, which a plain
   `justify-content: center` row cannot do because the birthday sitting beside
   it would shift the name left. A 1fr / auto / 1fr grid keeps the middle
   column centred no matter how wide the birthday is. */
#home-hero-id {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  width: 100%;
  margin: 18px 0 8px;
}

#home-hero-name {
  grid-column: 2;
  margin: 0;
  color: #fff;
  font-size: 2.2em;
  font-weight: 600;
  line-height: 1.3;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}

#home-hero-subtitle {
  margin: 0 0 20px;
  color: rgba(255, 255, 255, .9);
  font-size: 1.05em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .45);
}

/* Birthday sits in the column to the right of the centred name, but must not
   read as a link: no border, no background, just a small muted caption. */
#home-hero-birthday {
  grid-column: 3;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-left: 14px;
  color: rgba(255, 255, 255, .72);
  font-size: .82em;
  line-height: 1.6;
  letter-spacing: .04em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}

#home-hero-birthday i {
  font-size: .95em;
  opacity: .85;
}

#home-hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.home-hero-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .14);
  color: #fff !important;
  font-size: 1em;
  line-height: 1;
  backdrop-filter: blur(4px);
  transition: background .25s, border-color .25s, transform .25s,
    width .3s ease, gap .3s ease;
}

/* The site name is only revealed on hover / keyboard focus, so the row stays
   a compact set of icons. */
.home-hero-link-label {
  display: inline-block;
  max-width: 0;
  margin-left: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: .92em;
  opacity: 0;
  transition: max-width .3s ease, margin-left .3s ease, opacity .2s ease;
}

.home-hero-link:hover,
.home-hero-link:focus-visible {
  width: auto;
  padding: 0 16px;
  gap: 8px;
  background: rgba(255, 255, 255, .3);
  border-color: rgba(255, 255, 255, .85);
  transform: translateY(-2px);
}

.home-hero-link:hover .home-hero-link-label,
.home-hero-link:focus-visible .home-hero-link-label {
  max-width: 8em;
  margin-left: 1px;
  opacity: 1;
}

/* ---------- merged feed ---------- */
/* The id is reused on purpose: the theme's main.js runs its lightbox and
   justified-gallery setup against #article-container. */
#article-container.home-feed {
  padding: 0;
  background: none;
  box-shadow: none;
}

.home-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.home-card {
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(7, 17, 27, .06);
  text-align: left;
  transition: box-shadow .3s;
}

.home-card:hover {
  box-shadow: 0 4px 16px rgba(7, 17, 27, .12);
}

.home-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  font-size: .88em;
  opacity: .72;
}

.home-badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--btn-bg);
  color: #fff;
  font-size: .82em;
  line-height: 1.7;
}

.home-badge--moment { background: #ff7242; }

.home-card-date { color: inherit !important; }

.home-card-title {
  margin: 0 0 10px;
  font-size: 1.32em;
  line-height: 1.55;
}

.home-card-title a { color: inherit !important; }
.home-card-title a:hover { color: var(--btn-bg) !important; }

.home-card-body { line-height: 1.9; }
.home-card-body p { margin: 0 0 .8em; }
.home-card-body p:last-child { margin-bottom: 0; }
.home-card-body img { max-width: 100%; border-radius: 8px; }

/* ---------- image grid (Twitter / 朋友圈 style) ---------- */
/* A run of images becomes one grid, whether they were written on the same line
   or separated by blank lines. source/js/home.js builds the wrapper and adds
   the --two / --four / --many modifier from the image count. */

.img-grid {
  display: grid;
  gap: 4px;
  margin: 10px 0 12px;
  max-width: 100%;
}

.img-grid--two,
.img-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.img-grid--many { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* the theme's lightbox wraps each image in <a>, which becomes the grid item */
.img-grid > a,
.img-grid > img {
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(0, 0, 0, .04);
}

.img-grid > a,
.img-grid > img,
.img-grid > a > img {
  aspect-ratio: 1 / 1;
}

.img-grid img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  border-radius: 8px;
}

/* a lone image keeps its own proportions, only capped so it cannot dominate */
.home-card-body p.img-single,
.shuoshuo-content p.img-single {
  margin: 10px 0 12px;
}

.home-card-body p.img-single img,
.shuoshuo-content p.img-single img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 520px;
  border-radius: 8px;
}

/* a two-image grid reads better slightly landscape than dead square */
.img-grid--two > a,
.img-grid--two > img,
.img-grid--two > a > img { aspect-ratio: 4 / 5; }

.home-card-tax {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.home-chip {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(73, 177, 245, .12);
  color: var(--btn-bg) !important;
  font-size: .82em;
  transition: background .25s;
}

.home-chip:hover { background: rgba(73, 177, 245, .26); }

.home-chip--tag {
  background: rgba(0, 0, 0, .05);
  color: inherit !important;
}

[data-theme="dark"] .home-chip--tag { background: rgba(255, 255, 255, .1); }

.home-card-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  color: var(--btn-bg) !important;
  font-size: .9em;
}

.home-feed-empty {
  padding: 48px 20px;
  text-align: center;
  opacity: .7;
}

/* pagination sits inside the feed container (see layout/archive.pug) */
.home-feed #pagination {
  margin-top: 6px;
}

@media screen and (max-width: 768px) {
  #home-hero-name { font-size: 1.7em; }
  #home-hero-id { margin-top: 14px; }
  #home-hero-birthday { padding-left: 10px; font-size: .76em; }
  .home-hero-link { width: 38px; height: 38px; }
  .home-card { padding: 15px 16px; }
  .home-card-title { font-size: 1.15em; }
}

/* Short viewports: the hero is a fixed 100vh, so trim the spacing and type as
   vertical room runs out. This is what keeps the avatar able to stay a circle
   instead of being squeezed by the flex container. */
@media screen and (max-height: 620px) {
  #home-hero-inner { padding: 66px 20px 26px; }
  #home-hero-name { font-size: 1.75em; }
  #home-hero-subtitle { margin-bottom: 14px; font-size: .95em; }
  #home-hero-id { margin: 10px 0 4px; }
  .home-hero-link { width: 36px; height: 36px; }
}

@media screen and (max-height: 460px) {
  #home-hero-inner { padding: 54px 16px 14px; }
  #home-hero-name { font-size: 1.4em; }
  #home-hero-subtitle { margin-bottom: 10px; font-size: .86em; }
  #home-hero-id { margin: 6px 0 2px; }
  #home-hero-birthday { font-size: .72em; }
  #home-hero-links { gap: 7px; }
  .home-hero-link { width: 32px; height: 32px; }
  .home-hero-link i { font-size: .9em; }
}
