/*
 * 三個系統共用的小元件：左下角的「主選單」按鈕、頁首右邊的頭像（點了看個人資料、改密碼）和「登出」按鈕。
 * 入口網站、作品優化、順安的討論板都載入這一份，長得才會一樣。
 * 討論板的按鈕和頭像由 deploy/discussion/portal-login.mjs 在送出他的頁面時加上去（他的檔案不改）。
 * 顏色用三個系統共同的顏色變數；深色模式跟著系統設定。
 */

/* ---------- 左下角「主選單」 ---------- */
.portal-home {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px 10px 14px;
  font: 650 15px/1 "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--accent, #2f5bd4);
  text-decoration: none;
  background: var(--surface, #ffffff);
  border: 1px solid var(--accent-border, #b9cbf5);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(20, 28, 38, 0.16);
}
.portal-home:hover { background: var(--accent-soft, #eaf0fd); }
.portal-home:focus-visible { outline: 2px solid var(--accent, #2f5bd4); outline-offset: 2px; }
.portal-home svg { width: 18px; height: 18px; }

/* 頁面最下面留一點空間，按鈕才不會蓋住最後一行 */
body:has(.portal-home) { padding-bottom: 72px; }

/* ---------- 頁首的頭像 ---------- */
.portal-avatar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 12px 4px 4px;
  color: var(--text, #1c2126);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 999px;
}
.portal-avatar:hover { background: var(--accent-soft, #eaf0fd); }
.portal-avatar:focus-visible { outline: 2px solid var(--accent, #2f5bd4); outline-offset: 2px; }
.portal-avatar__circle {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft, #eaf0fd);
  border: 1px solid var(--accent-border, #b9cbf5);
  color: var(--accent, #2f5bd4);
  font-size: 15px;
  font-weight: 700;
}
/* 個人資料頁上面的大頭像 */
.portal-avatar__circle.big { width: 64px; height: 64px; font-size: 26px; }

/* ---------- 頁首的「登出」：一塊按鈕，跟討論板一般按鈕同一個樣子，放在頭像旁邊 ---------- */
.portal-logout,
.btn.btn--portal-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 38px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--text, #1c2126);
  background: var(--surface, #ffffff);
  border: 1px solid var(--border-strong, #c3c9d1);
  border-radius: var(--radius-md, 10px);
  text-decoration: none;
  cursor: pointer;
}
.portal-logout:hover,
.btn.btn--portal-logout:hover:not(:disabled) {
  color: var(--text, #1c2126);
  background: var(--surface-sunken, #f0f2f5);
  border-color: var(--border-strong, #c3c9d1);
}
.portal-logout:focus-visible,
.btn.btn--portal-logout:focus-visible { outline: 2px solid var(--accent, #2f5bd4); outline-offset: 2px; }

/* 頁首是主色底：頭像的字、登出按鈕改成白色系 */
.app-header .portal-avatar { color: #ffffff; }
.app-header .portal-avatar:hover { background: rgba(255, 255, 255, 0.12); }
.app-header .portal-avatar__circle { background: #ffffff; border-color: #ffffff; color: var(--header-bg, #0f766e); }
.app-header .portal-logout,
.app-header .btn.btn--portal-logout {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.42);
}
.app-header .portal-logout:hover,
.app-header .btn.btn--portal-logout:hover:not(:disabled) {
  color: var(--header-bg, #0f766e);
  background: #ffffff;
  border-color: #ffffff;
}

/* 窄螢幕：只留圓圈，名字收起來 */
@media (max-width: 480px) {
  .portal-avatar { padding-right: 4px; }
  .portal-avatar__name { display: none; }
}

@media (prefers-color-scheme: dark) {
  .portal-home { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
}
