/* apotatos.com 域名地图 —— 基础样式
   配色全部走 CSS 变量，亮暗两套；几何体与小球在 bg-layer 里，不参与命中测试。 */

:root {
  --bg: #F7F7F5;
  --text: #1A1A1A;
  --text-dim: rgba(26, 26, 26, 0.72);
  --text-faint: rgba(26, 26, 26, 0.62);
  --line: rgba(26, 26, 26, 0.1);
  --hover: rgba(26, 26, 26, 0.045);

  /* 立方体三个面分开给色，才能做出等距立体感 */
  --geo-cube-top: #A6D6EA;
  --geo-cube-left: #86BDD6;
  --geo-cube-right: #6FA8C4;
  --geo-circle: #FFD60A;
  --geo-tri: #90EE90;
  --geo-opacity: 0.5;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;

  --max: 820px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111315;
    --text: #E8E8E8;
    --text-dim: rgba(232, 232, 232, 0.72);
    --text-faint: rgba(232, 232, 232, 0.5);
    --line: rgba(255, 255, 255, 0.12);
    --hover: rgba(255, 255, 255, 0.05);

    --geo-cube-top: #2E5896;
    --geo-cube-left: #1B3A6B;
    --geo-cube-right: #142C52;
    --geo-circle: #8A6D00;
    --geo-tri: #14532D;
    --geo-opacity: 0.62;
  }
}

:root[data-theme="dark"] {
  --bg: #111315;
  --text: #E8E8E8;
  --text-dim: rgba(232, 232, 232, 0.72);
  --text-faint: rgba(232, 232, 232, 0.5);
  --line: rgba(255, 255, 255, 0.12);
  --hover: rgba(255, 255, 255, 0.05);

  --geo-cube-top: #2E5896;
  --geo-cube-left: #1B3A6B;
  --geo-cube-right: #142C52;
  --geo-circle: #8A6D00;
  --geo-tri: #14532D;
  --geo-opacity: 0.62;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}

/* 让滚动条、输入控件这类浏览器原生 UI 跟着主题走 */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
  }
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.25s, color 0.25s;
}

/* ----------------------------------------------------------------- 背景层 */

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.geo {
  position: fixed;
  pointer-events: none;
  opacity: var(--geo-opacity);
  transition: opacity 0.3s;
}

/* 定位思路：内容列 820px 居中，几何体全部丢到两侧空白带里。
   max(…) 保证视口再窄也不会被推到屏幕外；窄到这个程度就靠下面的媒体查询缩小。 */
.geo-cube {
  display: block;
  width: 100px;
  height: auto;
  top: 12vh;
  left: max(20px, calc(50% - 548px));
  animation: geo-float 11s ease-in-out infinite;
}
.geo-cube .cube-top { fill: var(--geo-cube-top); }
.geo-cube .cube-left { fill: var(--geo-cube-left); }
.geo-cube .cube-right { fill: var(--geo-cube-right); }

.geo-circle {
  width: 104px;
  height: 104px;
  top: 42vh;
  right: max(20px, calc(50% - 548px));
  background: var(--geo-circle);
  border-radius: 50%;
  animation: geo-float 13s ease-in-out 1.4s infinite;
}

.geo-tri {
  width: 106px;
  height: 94px;
  bottom: 12vh;
  left: max(20px, calc(50% - 548px));
  background: var(--geo-tri);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  animation: geo-float 15s ease-in-out 2.8s infinite;
}

/* 轻微浮动：三个错开时长与延迟，避免整齐划一像在呼吸 */
@keyframes geo-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -10px, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .geo {
    animation: none;
  }
}

/* 内容列两侧空白变窄：缩小几何体，继续贴住边缘 */
@media (max-width: 1180px) {
  .geo-cube {
    width: 76px;
    left: max(16px, calc(50% - 500px));
  }
  .geo-circle {
    width: 78px;
    height: 78px;
    right: max(16px, calc(50% - 500px));
  }
  .geo-tri {
    width: 80px;
    height: 72px;
    left: max(16px, calc(50% - 500px));
  }
}

/* 内容列已经贴边：左侧只剩 24px 余量，放任何几何体都会压住序号与图标。
   全部改到视口下方的空白带，并压低存在感。 */
@media (max-width: 940px) {
  .geo {
    opacity: 0.3;
  }
  .geo-cube {
    width: 64px;
    top: auto;
    bottom: 28vh;
    left: 10px;
  }
  .geo-circle {
    width: 66px;
    height: 66px;
    top: auto;
    bottom: 16vh;
    right: 10px;
  }
  .geo-tri {
    width: 68px;
    height: 60px;
    bottom: 6vh;
    left: 38%;
  }
}

@media (max-width: 640px) {
  /* 手机上内容列吃掉整屏，几何体放哪都会压到字。
     干脆全部推到视口下半部的空白带，再把存在感压到很低。 */
  .geo {
    opacity: 0.18;
  }
  .geo-cube {
    width: 46px;
    top: auto;
    bottom: 24vh;
    left: 6px;
  }
  .geo-circle {
    width: 48px;
    height: 48px;
    top: auto;
    bottom: 15vh;
    right: 8px;
  }
  .geo-tri {
    width: 50px;
    height: 44px;
    bottom: 6vh;
    left: 38%;
  }
}

/* 物理小球：由 main.js 动态创建，位置全靠 transform，不参与布局与命中 */
.ball {
  position: fixed;
  top: 0;
  left: 0;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
  /* 会从正文下穿过，压低一点存在感，别抢字 */
  opacity: 0.72;
}

/* ----------------------------------------------------------------- 顶部栏 */

.topbar {
  position: relative;
  z-index: 1;
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.4rem 1.5rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
}

.brand-arrow {
  font-size: 1rem;
  color: var(--text-dim);
  line-height: 1;
}

.theme-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.18s, border-color 0.18s, color 0.18s;
}

.theme-toggle:hover {
  background: var(--hover);
  border-color: var(--text-faint);
  color: var(--text);
}

.theme-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--text-dim);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- 列表 */

.content {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.6rem 1.5rem 5rem;
}

.link-list {
  display: flex;
  flex-direction: column;
}

.link-item {
  display: block;
  padding: 1rem 0.25rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.16s;
}

.link-item:last-child {
  border-bottom: 0;
}

.link-item:hover {
  background: var(--hover);
}

.link-item:focus-visible {
  outline: 2px solid var(--text-dim);
  outline-offset: -2px;
  border-radius: 8px;
}

.link-head {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* 站点图标：默认是首字母色块，favicon 加载成功后被替换（见 main.js 的 makeIcon） */
.link-icon {
  flex: none;
  align-self: center;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: var(--icon-bg, var(--text-faint));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
  transition: background-color 0.2s;
}

.link-icon.has-img {
  background: transparent;
}

.link-icon-letter {
  display: block;
}

.link-icon.has-img .link-icon-letter {
  display: none;
}

.link-icon-img {
  display: block;
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.link-no {
  flex: none;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.link-name {
  font-size: 1.02rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.link-domain {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  overflow-wrap: anywhere;
}

.link-desc {
  margin: 0.3rem 0 0;
  /* 与「名称」左边缘对齐：序号宽 + 间距 + 图标 20px + 间距 */
  padding-left: 3.55rem;
  font-size: 0.88rem;
  color: var(--text-dim);
  /* 避免窄屏上最后一行只剩一个字（不支持的浏览器会忽略这行） */
  text-wrap: pretty;
}

.list-hint {
  margin: 2rem 0 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 1.1rem 1.1rem 0.7rem;
  }

  .content {
    padding: 0.4rem 1.1rem 4rem;
  }

  .link-item {
    padding: 0.85rem 0.15rem;
  }

  .link-no {
    font-size: 0.76rem;
  }

  .link-icon {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }

  .link-icon-img {
    width: 14px;
    height: 14px;
  }

  .link-name {
    font-size: 0.98rem;
  }

  /* 和名称左缘对齐：序号 14.6 + 间距 8 + 图标 18 + 间距 8 ≈ 49px */
  .link-desc {
    padding-left: 3.1rem;
    font-size: 0.84rem;
  }
}
