/*
 * georgel.icu additions on top of Volantis 5.7.6.
 * Only for features the old theme did not have; everything uses the theme's
 * own variables (--color-card, --color-text, --color-meta …) so dark mode works.
 */

/* ------------------------------------------------------------ home: masonry feed */
/* Without JS: a plain responsive grid. With JS (MiniMasonry): absolute positioning. */
#l_main.masonry-home .masonry-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  align-items: start;
}
#l_main.masonry-home.masonry-ready .masonry-feed {
  display: block;
  position: relative;
  transition: transform 0.25s ease;
}
#l_main.masonry-home.masonry-ready .masonry-feed > .mcard {
  position: absolute;
  top: 0;
  left: 0;
}

/* Cards: flat until hovered; cover keeps its own ratio (staggered heights)
   but is clamped to 3:4 … 4:3 so very tall screenshots don't take half a screen. */
.mcard {
  container-type: inline-size;
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-card);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.25s ease, translate 0.25s ease;
}
.mcard:hover {
  translate: 0 -3px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.08), 0 8px 16px 0 rgba(0, 0, 0, 0.08);
}
.mcard-link {
  display: block;
  color: inherit;
}
.mcard-cover img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 75cqw;
  max-height: 133.33cqw;
  object-fit: cover;
}
.mcard-body {
  padding: 12px 14px 14px;
}
.mcard-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: bold;
  line-height: 1.5;
  color: var(--color-h2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mcard-title .fa-thumbtack {
  color: #ff5722;
  font-size: 0.8em;
}
.mcard-link:hover .mcard-title {
  color: #ff5722;
}
.mcard-desc {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--color-meta);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* text-only cards: bigger title, accent bar, a few lines of excerpt */
.mcard-text .mcard-body {
  padding: 16px 16px 14px;
}
.mcard-text .mcard-title {
  font-size: 1.125rem;
  -webkit-line-clamp: 3;
  padding-left: 10px;
  border-left: 3px solid #3dd9b6;
  margin-bottom: 10px;
}
.mcard-text .mcard-desc {
  -webkit-line-clamp: 3;
}
@media (max-width: 600px) {
  .mcard-body,
  .mcard-text .mcard-body {
    padding: 10px 12px 12px;
  }
  .mcard-text .mcard-title {
    font-size: 1rem;
    padding-left: 8px;
  }
}
.mcard-meta {
  font-size: 0.75rem;
  color: var(--color-meta);
  opacity: 0.8;
  white-space: nowrap;
}
.masonry-status {
  padding: 16px 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-meta);
}

/* The theme sidebar is not used on the home page: the feed takes the full width. */
#l_main.masonry-home,
#l_main.masonry-home.no_sidebar {
  width: 100%;
  max-width: none;
  padding-right: 0;
}
#l_main.masonry-home ~ #l_side {
  display: none;
}
/* The feed is a clearly narrower column than the header bar (reads as
   intentional, and leaves room on the left for the info panel). */
#l_main.masonry-home .home-feed {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

/* ------------------------------------------------------------ floating info panel (all pages) */
/* Top-left, frosted glass, deliberately unlike the white content cards. The
   background is the theme's card colour made translucent, so dark mode follows. */
.float-panel,
.fp-open {
  position: fixed;
  left: 16px;
  top: 88px;
  z-index: 99;
}
.float-panel {
  width: 220px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 22px 18px 18px;
  box-sizing: border-box;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.72);
  background: color-mix(in srgb, var(--color-card) 62%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  color: var(--color-text);
  text-align: left;
  transition: opacity 0.25s ease, background-color 0.3s ease, border-color 0.3s ease,
    -webkit-backdrop-filter 0.3s ease, backdrop-filter 0.3s ease;
}
/* Desktop: no box at all — the info sits straight on the page background,
   and is narrower so the home feed has to move as little as possible.
   (Phones keep the frosted box: there it opens over the content.) */
@media screen and (min-width: 769px) {
  .float-panel {
    width: 164px;
    padding: 6px 0 0;
    border: none;
    border-radius: 0;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
.float-panel a {
  color: inherit;
}
.float-panel a:hover {
  color: #ff5722;
}
/* Empty slot: the round avatar button (.fp-open) sits exactly on top of it in
   both states, so the avatar never moves — only the rest fades in and out. */
.fp-avatar {
  width: 56px;
  height: 56px;
}
.fp-name {
  display: block;
  margin: 10px 0 6px;
  font-size: 1rem;
  font-weight: bold;
  color: var(--color-h2);
}
.fp-social {
  display: flex;
  justify-content: flex-start;
  gap: 16px;
  font-size: 0.95rem;
  color: var(--color-meta);
}
.fp-title {
  margin: 18px 0 8px;
  padding-top: 14px;
  border-top: 1px dashed rgba(127, 127, 127, 0.3);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--color-meta);
  text-align: left;
}
.fp-bio {
  margin: 14px 0 0;
  font-size: 0.8125rem;
  line-height: 1.75;
  color: var(--color-p);
}
.fp-recent {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}
.fp-recent li {
  padding: 7px 0;
}
.fp-recent li + li {
  border-top: 1px dashed rgba(127, 127, 127, 0.2);
}
.fp-recent a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.8125rem;
  line-height: 1.55;
}
.fp-recent time {
  display: block;
  margin-top: 2px;
  font-size: 0.6875rem;
  color: var(--color-meta);
}

/* The round avatar: always shown, same place open or collapsed; click toggles. */
.fp-open {
  top: 94px;
  z-index: 100;
  display: block;
  width: 56px;
  height: 56px;
  padding: 0;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.25s ease;
}
.fp-open:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
.fp-open img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Open: items fade in top to bottom. Collapse: they fade out bottom to top,
   then become hidden (not focusable). --i is each item's order. */
.float-panel > .fp-name { --i: 0; }
.float-panel > .fp-social { --i: 1; }
.float-panel > .fp-bio { --i: 2; }
.float-panel > .fp-title { --i: 3; }
.float-panel > .fp-recent { --i: 4; }
.float-panel > :not(.fp-avatar) {
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s linear;
  transition-delay: calc(var(--i, 0) * 60ms);
}
#l_main.fp-collapsed:not(.fp-peek) .float-panel {
  pointer-events: none;
}
#l_main.fp-collapsed:not(.fp-peek) .float-panel > :not(.fp-avatar) {
  opacity: 0;
  transform: translateY(-6px);
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear;
  transition-delay: calc((4 - var(--i, 0)) * 40ms), calc((4 - var(--i, 0)) * 40ms),
    calc((4 - var(--i, 0)) * 40ms + 200ms);
}
/* Hover peek (desktop): where the panel would cover content, it gets a frosted
   backing. Box grows outward by 12px so its contents stay exactly in place. */
#l_main.fp-peek-over .float-panel {
  left: 4px;
  top: 76px;
  width: 188px;
  padding: 18px 12px 12px;
  border-radius: 16px;
}
#l_main.fp-peek-over.fp-peek .float-panel {
  background: rgba(255, 255, 255, 0.8);
  background: color-mix(in srgb, var(--color-card) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

/* Until float-panel.js has applied the remembered open/collapsed state, show
   neither the panel nor the avatar (otherwise the panel flashes on reload). */
#l_main:not(.fp-ready) .float-panel,
#l_main:not(.fp-ready) .fp-open,
#l_main:not(.fp-ready) .toc-float {
  visibility: hidden !important;
}
/* set while the page (re)loads, so the initial state appears without animating */
#l_main.fp-noanim .float-panel,
#l_main.fp-noanim .float-panel > *,
#l_main.fp-noanim .fp-open {
  transition: none !important;
}

/* ------------------------------------------------------------ article pages: floating TOC (right) */
/* Like sspai: a column of short dashes, one per heading; hover (or pin) shows
   the titles. Volantis' own TOC script marks the current heading .active-current. */
.toc-float {
  position: fixed;
  right: 16px;
  top: 50%;
  z-index: 98;
  transform: translateY(-50%);
  transition: opacity 0.25s ease;
}
.toc-float .tf-list {
  max-height: 70vh;
  overflow-y: auto;
  scrollbar-width: none;
}
.toc-float .tf-list::-webkit-scrollbar {
  display: none;
}
.toc-float ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.toc-float .tf-pin {
  display: none;
  margin: 0 0 6px auto;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-meta);
  cursor: pointer;
}
.toc-float .tf-pin:hover,
.toc-float.tf-pinned .tf-pin {
  color: #3dd9b6;
}
/* No layout transitions here (the theme animates every <a> property, which made
   the titles look squeezed in); titles and background fade in instead. */
.toc-float .toc-link {
  transition: color 0.2s ease, border-color 0.2s ease;
}
@keyframes tf-fade {
  from { opacity: 0; transform: translateX(6px); }
  to { opacity: 1; transform: none; }
}
/* mini mode */
.toc-float .toc-link {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 14px;
  color: var(--color-meta);
}
.toc-float .toc-text {
  display: none;
}
.toc-float .toc-link::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: rgba(127, 127, 127, 0.35);
  transition: background 0.2s ease, width 0.2s ease;
}
.toc-float .toc-level-3 > .toc-link::after {
  width: 12px;
}
.toc-float .toc-level-4 > .toc-link::after {
  width: 8px;
}
.toc-float li.active-current > .toc-link::after {
  width: 22px;
  background: #3dd9b6;
}
/* expanded: hover, pinned, or opened from the header button on phones */
/* Expanded titles sit directly on the page background (no panel), like sspai. */
.toc-float:hover,
.toc-float.tf-pinned,
.toc-float.tf-open {
  width: 240px;
  padding: 10px 12px 12px;
  box-sizing: border-box;
}
.toc-float:hover .tf-pin,
.toc-float.tf-pinned .tf-pin,
.toc-float.tf-open .tf-pin {
  display: block;
}
.toc-float:hover .toc-link,
.toc-float.tf-pinned .toc-link,
.toc-float.tf-open .toc-link {
  display: block;
  height: auto;
  padding: 4px 0 4px 12px;
  border-left: 2px solid rgba(127, 127, 127, 0.2);
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc-float:hover .toc-text,
.toc-float.tf-pinned .toc-text,
.toc-float.tf-open .toc-text {
  display: inline-block;
  animation: tf-fade 0.22s ease both;
}
.toc-float:hover .tf-pin {
  animation: tf-fade 0.22s ease both;
}

.toc-float:hover .toc-link::after,
.toc-float.tf-pinned .toc-link::after,
.toc-float.tf-open .toc-link::after {
  display: none;
}
.toc-float:hover .toc-level-3 > .toc-link,
.toc-float.tf-pinned .toc-level-3 > .toc-link,
.toc-float.tf-open .toc-level-3 > .toc-link {
  padding-left: 24px;
}
.toc-float:hover .toc-level-4 > .toc-link,
.toc-float.tf-pinned .toc-level-4 > .toc-link,
.toc-float.tf-open .toc-level-4 > .toc-link {
  padding-left: 36px;
}
.toc-float li.active-current > .toc-link {
  border-left-color: #3dd9b6;
  color: var(--color-list-hl);
  font-weight: bold;
}

/* Panel and TOC show together with the theme's header bar */
#l_main.fp-on-cover .float-panel,
#l_main.fp-on-cover .fp-open,
#l_main.fp-on-cover .toc-float {
  opacity: 0;
  pointer-events: none;
}

@media screen and (max-width: 768px) {
  /* the frosted box grows around the avatar, which stays where it was */
  .float-panel {
    left: 8px;
    top: 68px;
    padding: 12px 16px 16px;
    width: min(260px, calc(100vw - 24px));
  }
  .fp-avatar,
  .fp-open {
    width: 40px;
    height: 40px;
  }
  .fp-open {
    /* panel left/top + its 1px border + padding */
    top: 81px;
    left: 25px;
  }
  #l_main.fp-collapsed:not(.fp-peek) .float-panel {
    border-color: transparent;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  /* the TOC only appears when opened from the header button */
  .toc-float {
    display: none;
  }
  /* on phones it opens over the article text, so it keeps a frosted background */
  .toc-float.tf-open {
    display: block;
    top: 76px;
    right: 12px;
    transform: none;
    width: min(260px, calc(100vw - 32px));
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.85);
    background: color-mix(in srgb, var(--color-card) 80%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
  }
  .toc-float .tf-pin {
    display: none !important;
  }
  /* the header TOC button (hidden inline by the theme) is shown on pages with a TOC */
  html.fp-has-toc .l_header .switcher .s-toc {
    display: flex !important;
  }
}

/* ---------------------------------------------------------------- footer
   Icons, then one quiet line of copyright, then the filing numbers (shown
   once src/beian.ts is filled). */
footer.footer .sf-copy,
footer.footer .sf-beian {
  margin: 0;
  font-size: 0.75rem;
  line-height: 2;
  color: var(--color-site-footer);
}
footer.footer .sf-copy { margin-top: 4px; }
footer.footer .sf-copy a,
footer.footer .sf-beian a {
  color: inherit;
  text-decoration: none;
  border-bottom: none;
}
footer.footer .sf-copy a:hover,
footer.footer .sf-beian a:hover { color: var(--color-list-hl); }
footer.footer .sf-beian { opacity: 0.85; }
footer.footer .sf-sep { margin: 0 0.3em; opacity: 0.6; }
footer.footer .sf-item { white-space: nowrap; }
footer.footer .sf-beian img {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin: 0 4px 0 0;
  vertical-align: -2px;
}

/* ---------------------------------------------------------------- comments */
#comments { margin-top: 16px; }
#comments .cmt-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-h2);
}
#comments .cmt-title i { margin-right: 6px; color: var(--color-meta); }
#comments .cmt-note { color: var(--color-meta); font-size: 0.875rem; }
#comments .cmt-privacy {
  margin: 14px 0 0;
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--color-meta);
}
/* Artalk follows the site's link colour */
#comments .artalk { --at-color-main: #30ad91; }
/* phones: break after the copyright item instead of leaving a stray "·" */
@media (max-width: 600px) {
  footer.footer .sf-copy .sf-item:first-child { display: block; }
  footer.footer .sf-copy .sf-item:first-child + .sf-sep { display: none; }
}
@media (max-width: 420px) {
  footer.footer .sf-beian .sf-item { display: block; }
  footer.footer .sf-beian .sf-sep { display: none; }
}
