/*!
 * fastlinks.css — ArnalHere 作品速览页（fastlinks.html）样式
 *
 * 一张卡片 = 预览图（.fl-frame）+ 数个链接（.fl-links）+ 类型标签 / 日期（.fl-meta）。
 * 两种视图共用同一份 DOM，只靠 body[data-view] 改布局，切换时不重建节点：
 *   grid（图标）：自适应多列，卡片竖排 —— 预览图在上，链接列表和类型/日期在下
 *   list（列表）：单列行 —— 预览图缩成左侧小缩略图，链接横排换行
 *
 * 没配预览图的卡片在图框位置放一个占位图标（fastlinks-icons.js 里的 FL_ICONS.link）。
 */

/* ===== 页面骨架 ===== */
.fl-main { padding: 7.5rem 0 5.5rem; }

.fl-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  max-width: 780px;
  margin: 0 auto 1.6rem;
  padding: 0 .1rem;
}

.fl-title {
  font-size: clamp(1.6rem, 3.4vw, 2.1rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.01em;
  color: var(--text);
}

.fl-sub {
  margin-top: .35rem;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--text-3);
}

/* ===== 右上角工具区（排序 + 视图） ===== */
.fl-tools {
  flex: none;
  display: flex;
  align-items: center;
  gap: .55rem;
}

/* 排序：文字胶囊，选中的一格用卡片底色+品牌色文字 */
.fl-sort {
  display: flex;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-soft);
  box-shadow: var(--sh-sm);
}

.fl-sort-btn {
  height: 32px;
  padding: 0 .8rem;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  font: inherit;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-3);
  cursor: pointer;
  transition: color .24s var(--ease), background-color .24s var(--ease),
    box-shadow .24s var(--ease);
}
.fl-sort-btn:hover { color: var(--text-2); }
.fl-sort-btn[aria-pressed="true"] {
  background: var(--bg-card);
  color: var(--c-primary);
  box-shadow: var(--sh-sm);
}
.fl-sort-btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* ===== 视图切换器 ===== */
.fl-switch {
  position: relative;
  flex: none;
  display: flex;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-soft);
  box-shadow: var(--sh-sm);
}

/* 选中态的滑块：两格各占一半，靠位移切换 */
.fl-switch-thumb {
  position: absolute;
  top: 4px; left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: var(--r-full);
  background: var(--bg-card);
  box-shadow: var(--sh-md);
  transition: transform .3s var(--ease-out), background-color .4s var(--ease);
}
body[data-view="list"] .fl-switch-thumb { transform: translateX(100%); }

.fl-switch-btn {
  position: relative;
  z-index: 1;
  width: 38px; height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color .24s var(--ease);
}
.fl-switch-btn svg { width: 17px; height: 17px; display: block; }
.fl-switch-btn:hover { color: var(--text-2); }
.fl-switch-btn[aria-pressed="true"] { color: var(--c-primary); }

/* 管理入口：与上面两个切换器同高同底色，图标按钮，指向 fastlinks-admin.html */
.fl-admin {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-soft);
  box-shadow: var(--sh-sm);
  color: var(--text-3);
  transition: color .24s var(--ease), border-color .24s var(--ease),
    transform .24s var(--ease), background-color .4s var(--ease);
}
.fl-admin svg { width: 17px; height: 17px; display: block; }
.fl-admin:hover {
  color: var(--c-primary);
  border-color: var(--c-primary);
  transform: translateY(-1px);
}
.fl-admin:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 3px; }
.fl-switch-btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* ===== 分组 ===== */
.fl-group + .fl-group { margin-top: 1.5rem; }

.fl-group-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  max-width: 780px;
  margin: 0 auto .8rem;
  padding: 0 .15rem;
}

.fl-group-dot {
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c-primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}

.fl-group-title {
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ===== 条目（两种视图共用） =====
   一张卡片 = 预览图（.fl-frame）+ 数个链接（.fl-links）+ 类型标签和日期（.fl-meta）。 */
.fl-grid {
  max-width: 780px;
  margin: 0 auto;
}

.fl-item {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  isolation: isolate;
  transition: transform .28s var(--ease-out), border-color .28s var(--ease),
    box-shadow .28s var(--ease), background-color .4s var(--ease);
}

/* 品牌色光晕，悬停时亮起 */
.fl-item::before {
  content: '';
  position: absolute;
  top: -64px; right: -46px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: var(--c-primary);
  filter: blur(42px);
  opacity: .14;
  z-index: -1;
  transition: opacity .32s var(--ease), transform .45s var(--ease);
}

.fl-item:hover {
  border-color: color-mix(in srgb, var(--c-primary) 50%, var(--border));
  box-shadow: var(--sh-md);
}
.fl-item:hover::before { opacity: .28; transform: scale(1.1); }
.fl-item:focus-within {
  border-color: color-mix(in srgb, var(--c-primary) 50%, var(--border));
  box-shadow: var(--sh-md);
}

/* 预览图框：整宽、固定 1:1 方形（图 cover 铺满；没图的卡片里放占位图标）。
   上传什么比例都行，展示层统一裁成正方形。 */
.fl-frame {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.fl-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .45s var(--ease-out);
}
.fl-item:hover .fl-img { transform: scale(1.04); }

/* 占位图标：卡片没配预览图时顶上 */
.fl-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 10px 20px -12px rgba(79, 70, 229, .9);
}
.fl-icon svg { width: 26px; height: 26px; display: block; }

.fl-text {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .6rem .6rem .65rem;
}

/* 卡片标题：显示在链接列表上方；列表视图里字稍小 */
.fl-title {
  min-width: 0;
  margin: 0;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 链接列表：一行三个按钮，名称 + 出口小箭头；放不下自动换行 */
.fl-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .35rem;
  min-width: 0;
}

.fl-link {
  display: flex;
  align-items: center;
  gap: .35rem;
  min-width: 0;
  padding: .3rem .4rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: color .22s var(--ease), border-color .22s var(--ease),
    background-color .22s var(--ease);
}
.fl-link:hover {
  color: var(--c-primary);
  border-color: color-mix(in srgb, var(--c-primary) 55%, var(--border));
  background: color-mix(in srgb, var(--c-primary) 7%, var(--bg-card));
}
.fl-link:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 1px; }

.fl-link-name {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fl-link-go {
  flex: none;
  display: grid;
  place-items: center;
  color: inherit;
  opacity: .6;
}
.fl-link-go svg { width: 13px; height: 13px; display: block; }

/* 站内链接箭头朝右，外链箭头朝外上 */
.fl-link .ext { display: none; }
.fl-link.is-ext .ext { display: block; }
.fl-link.is-ext .in { display: none; }

/* 类型标签 + 日期：类型靠左下、日期靠右下 */
.fl-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  min-width: 0;
}

.fl-type {
  flex: none;
  max-width: 70%;
  padding: .08rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-soft);
  font-size: .6563rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fl-date {
  margin-left: auto;                /* 推到卡片右下角 */
  min-width: 0;
  color: var(--text-3);
  font-size: .6875rem;
  line-height: 1.4;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  opacity: .8;
  white-space: nowrap;
}

/* ===== 图标视图（默认）：卡片多列平铺 ===== */
body[data-view="grid"] .fl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: .9rem;
}

body[data-view="grid"] .fl-item {
  border-radius: 18px;
}
body[data-view="grid"] .fl-item:hover { transform: translateY(-3px); }

body[data-view="grid"] .fl-frame {
  width: 100%;                        /* 高度由 aspect-ratio 1:1 决定 */
}

/* ===== 列表视图：单列行，预览图缩成小缩略图，链接横排换行 ===== */
body[data-view="list"] .fl-grid {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

body[data-view="list"] .fl-item {
  flex-direction: row;
  align-items: center;
  gap: .8rem;
  padding: .55rem .8rem .55rem .55rem;
  border-radius: 16px;
}
body[data-view="list"] .fl-item:hover { transform: translateX(3px); }

body[data-view="list"] .fl-frame {
  width: 64px;
  height: 64px;                       /* 列表缩略图也走 1:1 */
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 11px;
}
body[data-view="list"] .fl-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
}
body[data-view="list"] .fl-icon svg { width: 19px; height: 19px; }

body[data-view="list"] .fl-text {
  gap: .3rem;
  padding: 0;
}

body[data-view="list"] .fl-title {
  font-size: .8125rem;
}

body[data-view="list"] .fl-link {
  min-width: 0;
  padding: .18rem .4rem;
  font-size: .75rem;
}

body[data-view="list"] .fl-type { font-size: .625rem; }
body[data-view="list"] .fl-date { font-size: .625rem; }

/* 列表视图下分组之间留白更大，形成分隔感 */
body[data-view="list"] .fl-group + .fl-group { margin-top: 1.75rem; }

/* 列表行窄而长，光晕缩小调淡，避免糊成一片色块 */
body[data-view="list"] .fl-item::before {
  width: 120px; height: 120px;
  top: -40px; right: -60px;
  opacity: .08;
}
body[data-view="list"] .fl-item:hover::before { opacity: .16; }

/* ===== 进场动画 ===== */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
}
.reveal.in { opacity: 1; transform: none; }

/* 切换视图时给条目一个轻微的错落淡入 */
body.is-switching .fl-item { animation: fl-pop .34s var(--ease-out) both; }
@keyframes fl-pop {
  from { opacity: 0; transform: translateY(6px) scale(.985); }
  to { opacity: 1; transform: none; }
}

/* ===== 空状态（links 数组为空时） ===== */
.fl-empty {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.4rem 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  text-align: center;
  font-size: .875rem;
  line-height: 1.9;
  color: var(--text-3);
}
.fl-empty code {
  padding: .1rem .35rem;
  border-radius: 5px;
  background: var(--bg-sunken, rgba(127, 127, 127, .12));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8125rem;
  color: var(--text-2);
}

/* ===== 响应式 ===== */
@media (max-width: 720px) {
  .fl-main { padding: 6.5rem 0 3.5rem; }
  .fl-head { align-items: flex-start; flex-direction: column; gap: .9rem; margin-bottom: 1.25rem; }
  /* 工具区在两行排布时靠右，不挤占标题宽度 */
  .fl-tools { align-self: flex-end; gap: .45rem; }
  .fl-sort-btn { padding: 0 .6rem; font-size: .7188rem; }
  body[data-view="grid"] .fl-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .6rem; }
  body[data-view="grid"] .fl-item { border-radius: 15px; }
  body[data-view="grid"] .fl-icon { width: 42px; height: 42px; border-radius: 12px; }
  body[data-view="grid"] .fl-icon svg { width: 21px; height: 21px; }
  body[data-view="grid"] .fl-text { padding: .45rem .5rem .5rem; }
  body[data-view="grid"] .fl-link { font-size: .75rem; }
  /* 窄屏下列表视图也变成竖排卡（缩略图在上、链接在下），不然一行塞不下 */
  body[data-view="list"] .fl-item { flex-direction: column; align-items: stretch; gap: .5rem; padding: .5rem; }
  body[data-view="list"] .fl-frame { width: 100%; height: auto; aspect-ratio: 1 / 1; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .fl-item, .fl-icon, .fl-switch-thumb { transition: none; }
  body.is-switching .fl-item { animation: none; }
}

/* 暗色：光晕收敛一点，避免发灰 */
html[data-theme="dark"] .fl-item::before { opacity: .26; }
html[data-theme="dark"] .fl-item:hover::before { opacity: .4; }
html[data-theme="dark"] body[data-view="list"] .fl-item::before { opacity: .16; }
html[data-theme="dark"] body[data-view="list"] .fl-item:hover::before { opacity: .26; }
html[data-theme="dark"] .fl-group-dot { box-shadow: 0 0 0 4px rgba(129, 140, 248, .16); }
html[data-theme="dark"] .fl-switch-thumb { background: var(--bg-card); }
