/*
 * public/assets/styles.css — 前台品牌外殼的最小可行樣式。
 *
 * 對應任務 10.1：置中版面、CSS 變數承接主色、乾淨的頁尾樣式。此階段
 * 沒有頁籤或連結內容，故不含任何列表／卡片／導覽樣式，只涵蓋
 * public/index.php 目前實際渲染出的三個區塊（header／main／footer）。
 * --primary-color 由 public/index.php 以 inline <style> 或 body 的
 * style 屬性帶入（依當前站台品牌設定解析後的值），本檔只負責「有定義時
 * 怎麼用」；未帶入時回退到下方 :root 的預設值，避免樣式表被單獨引用或
 * 變數缺席時整頁失色。
 */

:root {
    --primary-color: #2563eb;
    --text-color: #1f2937;
    --muted-color: #6b7280;
    --bg-color: #f9fafb;
    --surface-color: #ffffff;
    --border-color: #e5e7eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    color: var(--text-color);
    background-color: #ffffff;
    line-height: 1.6;
}

.app-shell {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    box-shadow: none;
}

.app-header {
    padding: 1.5rem 1.5rem 0.75rem;
    border-bottom: none;
    flex-shrink: 0;
    text-align: center;
}

.site-branding {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    max-width: 100%;
}

.site-header-logo {
    max-height: 52px;
    width: auto;
    object-fit: contain;
    vertical-align: middle;
    border-radius: 6px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.site-header-logo:hover {
    transform: scale(1.04);
}

.app-header h1 {
    margin: 0;
    font-size: 1.75rem;
    color: var(--text-color);
    line-height: 1.3;
}

@media (max-width: 600px) {
    .site-branding {
        gap: 0.5rem;
    }
    .site-header-logo {
        max-height: 40px;
    }
    .app-header h1 {
        font-size: 1.35rem;
    }
}

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
    color: var(--muted-color);
}

/*
 * 任務 4.3：內容區內部捲動（僅在被嵌入時生效）。
 *
 * 對應 openspec/changes/portal-content/specs/embed-integration/spec.md
 * 「Content scrolls internally when the parent does not resize the
 * iframe」：「the public page SHALL keep the tab bar visible and SHALL
 * allow the content region to scroll within the available height,
 * rather than truncating content」。
 *
 * `.is-embedded` class 由 public/assets/app.js 在偵測到
 * `window.self !== window.top`（本頁面正被某個瀏覽環境以 iframe 嵌入，
 * 不論是否同源）時加在 <html> 上。只在這個 class 存在時才把 .app-shell
 * 鎖定為剛好 100vh（在被嵌入的情況下，100vh 就是「目前這個 iframe 的
 * 可視高度」，不論那個高度是外部頁面固定寫死的值，還是接收腳本依
 * postMessage 動態調整後的值），讓 header／頁籤列／footer 保持固定
 * 大小，只有 .tab-panels（目前作用中頁籤的內容區）在自己的邊界內捲動
 * ——這樣訪客往下捲動內容時，頁籤列不會被捲出畫面，隨時可以再點其他
 * 頁籤，對應同一需求「no card is unreachable」與「the tab bar remains
 * visible」兩個逐句要求。
 *
 * 刻意不對「未被嵌入、訪客直接開啟本頁」的情況套用這組限制：直接開啟
 * 時本來就沒有「父頁面不調整 iframe 大小」這個前提（spec.md 需求本身
 * 的觸發條件是「When the parent page does not resize the iframe」），
 * 維持原本「整頁自然依內容高度延伸、瀏覽器自行處理捲動」的行為，不
 * 無謂改變既有直接瀏覽體驗。
 */
html.is-embedded .app-shell {
    max-height: 100vh;
    overflow: hidden;
}

html.is-embedded .app-main {
    overflow: hidden;
}

html.is-embedded .tab-panels {
    overflow-y: auto;
}

.app-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--muted-color);
    flex-shrink: 0;
    text-align: center;
}

.app-footer-admin-link {
    margin: 0.5rem 0 0 0;
    text-align: center;
}
.app-footer-admin-link a {
    color: var(--muted-color);
    text-decoration: none;
}
.app-footer-admin-link a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/*
 * 頁籤列與內容區（任務 2.2）。
 *
 * 對應 spec.md「Centered tab bar above content」：頁籤列在內容區域內水平
 * 置中排列在內容上方，白色背景（.app-shell 的 --surface-color 已是
 * #ffffff，此處沿用同一個變數，不另外硬寫顏色值）。
 *
 * 響應式（窄螢幕單行水平捲動）屬於「Responsive layout on small screens」
 * 需求，鍵盤焦點樣式屬於「Keyboard operation of the tab bar」需求，兩者都
 * 不在本任務交辦範圍內，本檔不處理；.tab-bar 加上 overflow-x: auto 只是
 * 避免頁籤過多時把版面撐壞的最低限度防線，不是完整的響應式實作。
 */

/*
 * 頁籤列與內容區（響應式強化）：
 * - 桌機：置中優雅排列
 * - 手機/平板：橫向平滑滑動（不折行擠壓），隱藏醜陋滾動條，觸控滑順
 */

.tab-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1.5rem 0;
    background-color: var(--surface-color);
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
}

.tab-item {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--border-color);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px; /* 與 tab-bar 底線無縫重合 */
    background-color: #f8fafc;
    color: var(--muted-color);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.65rem 1.25rem;
    border-radius: 0.5rem 0.5rem 0 0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.tab-item:hover {
    color: var(--text-color);
    background-color: #f1f5f9;
}

.tab-item.is-active {
    background-color: #ffffff;
    color: var(--primary-color);
    border-color: var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-bottom-color: #ffffff; /* 蓋住底部底線 */
    font-weight: 700;
}

.tab-lock-icon {
    font-size: 0.85rem;
}

.tab-panels {
    padding: 1.5rem 1rem;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center; /* 內容區塊整體水平置中 */
    width: 100%;
}

.tab-panel {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center; /* 面板內容置中 */
}

.tab-panel[hidden] {
    display: none;
}

.tab-panel-placeholder {
    color: var(--muted-color);
    text-align: center;
}

.tab-empty-message {
    padding: 2rem 1.5rem;
    color: var(--muted-color);
    text-align: center;
}

/*
 * 卡片格線置中自適應模式 (Card Grid Centered & Responsive)
 * 不論設定 1 欄、2 欄、3 欄或更多欄，皆在畫面中央完美置中排版
 */
.card-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(var(--grid-columns, 3), minmax(0, 1fr));
    gap: 1.25rem;
    justify-content: center;
    margin: 0 auto;
}

/* 針對不同欄數設定最佳置中寬度，避免 1 欄時被拉扯過長 */
.card-grid[data-column-count="1"] {
    max-width: 540px;
}

.card-grid[data-column-count="2"] {
    max-width: 820px;
}

.card-grid[data-column-count="3"] {
    max-width: 1080px;
}

.card-grid[data-column-count="4"],
.card-grid[data-column-count="5"],
.card-grid[data-column-count="6"] {
    max-width: 1240px;
}

/* 📱 手機模式（螢幕小於等於 768px）：頁籤水平滑動、卡片單欄置中排列 */
@media (max-width: 768px) {
    .app-main {
        padding: 0.75rem 0.5rem 2rem;
    }

    .tab-bar {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem 0.75rem 0;
        scrollbar-width: none; /* Firefox 隱藏滾動條 */
    }
    .tab-bar::-webkit-scrollbar {
        display: none; /* Chrome/Safari 隱藏滾動條 */
    }

    .tab-item {
        padding: 0.55rem 1rem;
        font-size: 0.9rem;
        flex-shrink: 0; /* 防止按鈕被壓縮變形 */
    }

    .tab-panels {
        padding: 1rem 0.5rem;
    }

    /* 手機強制單欄，極致舒適易讀 */
    .card-grid {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
        gap: 0.85rem;
    }

    .link-card {
        padding: 0.85rem 1rem;
    }

    .link-button {
        padding: 0.85rem 1rem;
        font-size: 1rem;
    }
}

/* 💻 平板模式（769px ~ 1024px）：最大 2~3 欄，避免寬度過窄擠爆 */
@media (min-width: 769px) and (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 1rem;
    }
    .card-grid[data-column-count="1"] {
        max-width: 540px;
    }
}

/*
 * .card-item 是三種呈現樣式共用的格線項目基底（任務 3.2）：只負責讓
 * <a> 元素能正常當 CSS grid 的子項目、清掉瀏覽器預設的底線與繼承文字
 * 色，其餘視覺樣式（邊框、按鈕配色、純文字連結底線等）交給下方
 * .link-card／.link-button／.link-text 三個樣式專屬 class，對應
 * spec.md「Three link presentation styles」需求「All styles SHALL
 * share the same ordering and the same grid」——共用的是格線與排序，
 * 不是視覺樣式本身。
 */
.card-item {
    display: block;
    text-decoration: none;
    color: inherit;
}

/*
 * embed 開啟方式（open_mode=embed）的連結是 <button> 而不是 <a>（任務
 * 3.3，spec.md「Three link opening modes」Example「embed | button」，見
 * public/index.php 的 $linkTag 計算）。瀏覽器對 <button> 有自己的預設
 * 外觀（邊框、背景、字型、置中對齊、寬度不撐滿），這裡重置掉，讓它套用
 * .link-card／.link-button／.link-text 之後與 <a> 版本視覺一致，不露出
 * 原生按鈕的邊框或跑版的文字對齊。
 */
button.card-item {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: none;
    font: inherit;
    text-align: inherit;
    cursor: pointer;
    width: 100%;
}

/*
 * card 樣式：圖示（選填）＋標題＋說明。
 *
 * .link-card__head 把圖示與標題放在同一行；icon 欄位為空時
 * public/index.php 完全不輸出 .link-icon 這個 <span>，flex 容器只剩
 * 一個子元素時 gap 不會產生空隙，因此不需要額外的「無圖示」修飾
 * class，對應 spec.md「Optional card icon」需求「SHALL NOT reserve
 * visible empty space for one」。
 */
.link-card {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    background-color: var(--bg-color);
    color: var(--muted-color);
    transition: border-color 0.15s ease;
}

.link-card:hover,
.link-card:focus-visible {
    /* spec.md「Three link presentation styles」需求「The site accent
       color SHALL continue to determine...the card hover border」。 */
    border-color: var(--primary-color);
}

.link-card__head {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.link-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.link-title {
    font-weight: 600;
    color: var(--text-color);
}

.link-description {
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted-color);
}

/* ==========================================================================
   投稿專用卡片樣式：水平排版、左側 4:3 比例縮圖截圖、推薦人與 20 字簡介
   ========================================================================== */
.link-card--submission {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.85rem;
    padding: 0.75rem;
    position: relative;
    overflow: hidden;
}

.submission-card-thumb {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    aspect-ratio: 4 / 3;
    height: 75px;
    border-radius: 6px;
    overflow: hidden;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submission-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}

.link-card--submission:hover .submission-card-thumb img {
    transform: scale(1.05);
}

.submission-card-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.2rem;
}

.submission-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-color);
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.submission-card-author {
    font-size: 0.78rem;
    color: #4f46e5;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    line-height: 1.2;
}

.submission-card-desc {
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.submission-card-foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: auto;
}

.btn-link-like {
    background: transparent;
    border: 1px solid #fed7aa;
    background-color: #fff7ed;
    border-radius: 9999px;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    color: #ea580c;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s ease;
}

.btn-link-like:hover, .btn-link-like.liked {
    background-color: #ffedd5;
    border-color: #f97316;
    transform: scale(1.06);
}

/*
 * button 樣式：純標題的實心按鈕，配色來自 public/index.php
 * link_render_button_combo_index() 依連結 id 求得的組合編號
 * （.link-button--combo-1 ~ 8，定義見下方）。懸停／鍵盤聚焦時上浮＋
 * 加深陰影，transition 約 150ms；偵測到降低動態偏好時移除位移與
 * transition，只靠背景色變化（各組合的 hover 背景，見下方）呈現互動
 * 狀態，對應 spec.md「Button style hover lift respects reduced
 * motion」需求。
 */
.link-button {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.link-button:hover,
.link-button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.16);
}

@media (prefers-reduced-motion: reduce) {
    .link-button {
        transition: background-color 150ms ease;
    }

    .link-button:hover,
    .link-button:focus-visible {
        transform: none;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    }
}

/*
 * 八組配色，逐字採用 spec.md「Button color combinations meet a
 * contrast threshold」需求表格中已驗證過對比度（文字對背景、文字對
 * hover 背景皆 ≥ 4.5:1）的數值。組合數（8）必須與
 * public/index.php link_render_button_combo_index() 的餘數運算基底
 * （% 8）一致，對應同一需求「The number of combinations known to the
 * selection function SHALL equal the number of combinations defined
 * in the stylesheet」。
 */
.link-button--combo-1 { background-color: #fee2e2; color: #991b1b; }
.link-button--combo-1:hover, .link-button--combo-1:focus-visible { background-color: #fecaca; }

.link-button--combo-2 { background-color: #ffedd5; color: #9a3412; }
.link-button--combo-2:hover, .link-button--combo-2:focus-visible { background-color: #fed7aa; }

.link-button--combo-3 { background-color: #fef3c7; color: #854d0e; }
.link-button--combo-3:hover, .link-button--combo-3:focus-visible { background-color: #fde68a; }

.link-button--combo-4 { background-color: #dcfce7; color: #166534; }
.link-button--combo-4:hover, .link-button--combo-4:focus-visible { background-color: #bbf7d0; }

.link-button--combo-5 { background-color: #ccfbf1; color: #115e59; }
.link-button--combo-5:hover, .link-button--combo-5:focus-visible { background-color: #99f6e4; }

.link-button--combo-6 { background-color: #dbeafe; color: #1e40af; }
.link-button--combo-6:hover, .link-button--combo-6:focus-visible { background-color: #bfdbfe; }

.link-button--combo-7 { background-color: #ede9fe; color: #5b21b6; }
.link-button--combo-7:hover, .link-button--combo-7:focus-visible { background-color: #ddd6fe; }

.link-button--combo-8 { background-color: #fce7f3; color: #9d174d; }
.link-button--combo-8:hover, .link-button--combo-8:focus-visible { background-color: #fbcfe8; }

/*
 * text 樣式：項目符號＋標題的純文字超連結。不取用按鈕配色組合（spec.md
 * 「Three link presentation styles」需求「The card and text styles
 * SHALL NOT take their colors from the button combinations」），沿用
 * 站台主色作為連結色。
 */
.link-text {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    padding: 0.5rem 0;
    color: var(--primary-color);
}

.link-text .link-title {
    font-weight: 400;
    color: var(--primary-color);
    text-decoration: underline;
}

.link-text:hover .link-title,
.link-text:focus-visible .link-title {
    text-decoration-thickness: 2px;
}

.link-bullet {
    color: var(--muted-color);
}

/*
 * 列數限制收摺：超出當前有效欄數 × max_rows 的項目由 app.js 加上這個
 * class 隱藏，而不是不渲染（spec.md「Hidden items SHALL remain reachable
 * through the control; the system SHALL NOT silently drop them」——項目
 * 一律留在 DOM 中，只是視覺隱藏，展開時移除這個 class 即可顯示，不需要
 * 重新請求或重新渲染任何內容）。
 */
.card-item.is-hidden-by-limit {
    display: none;
}

.expand-control {
    display: block;
    margin: 1.5rem auto 0;
    padding: 0.65rem 1.75rem;
    border: 1.5px solid var(--primary-color);
    border-radius: 2rem;
    background-color: var(--surface-color);
    color: var(--primary-color);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.expand-control:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.expand-control[hidden] {
    display: none;
}

/*
 * 嵌入型頁籤容器（任務 4.1）：embed_url 型在此渲染真正的 <iframe>
 * （見 public/index.php），寬度撐滿內容區、高度由 .embed-frame 的
 * inline style（tabs.embed_height，預設 600px）決定。sandbox 屬性、
 * 逾時降級的失敗訊息樣式留給任務 4.2／4.3。
 */
.embed-container {
    width: 100%;
}

.embed-frame {
    display: block;
    width: 100%;
    border: 0;
}

/* embed_srcdoc 型的 TODO 占位訊息（任務 4.2／4.3 補上實際渲染前的過渡樣式）。 */
.embed-pending-notice {
    padding: 2rem 1.5rem;
    border: 1px dashed var(--border-color);
    border-radius: 0.5rem;
    color: var(--muted-color);
    text-align: center;
}

/*
 * 站台／頁籤鎖定狀態與密碼輸入表單（任務 5.1／5.3）。
 *
 * .site-locked／.tab-locked 本身（任務 5.1 已建立）不需要額外版面樣式
 * ——.site-locked 直接沿用 .app-main 的置中排版，.tab-locked 是頁籤面板
 * 內唯一的子元素，不需要格線或卡片樣式。本任務（5.3）只新增
 * .passcode-form 相關樣式，讓提示文字、輸入框、送出按鈕、錯誤訊息在
 * 視覺上明顯是「同一組互動元件」，不是隨機散落的文字段落。
 */
.site-locked,
.tab-locked {
    text-align: center;
}

.site-locked__hint,
.tab-locked__hint {
    color: var(--muted-color);
    font-size: 0.9rem;
}

.passcode-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem auto 0;
    max-width: 24rem;
}

.passcode-form__label {
    /* 螢幕上不重複顯示「通關密碼」字樣（上方訊息文字已經講過一次
       「需要通關密碼」），但螢幕報讀器仍需要一個與 input 關聯的可讀
       標籤，因此保留 <label> 本身、只在視覺上隱藏，不用
       display:none（那樣部分螢幕報讀器會一併跳過不朗讀）。 */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.passcode-form__input {
    flex: 1 1 12rem;
    min-width: 0;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font: inherit;
    color: var(--text-color);
    background-color: var(--surface-color);
}

.passcode-form__input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

.passcode-form__submit {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.6rem 1.25rem;
    border: 1px solid var(--primary-color);
    border-radius: 0.5rem;
    background-color: var(--primary-color);
    color: var(--surface-color);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.passcode-form__submit:hover,
.passcode-form__submit:focus-visible {
    opacity: 0.9;
}

.passcode-form__submit:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.passcode-form__error {
    flex-basis: 100%;
    margin: 0;
    font-size: 0.9rem;
    color: #b91c1c;
}

.passcode-form__error[hidden] {
    display: none;
}

/* ==========================================================================
   前台投稿按鈕與 Modal 樣式
   ========================================================================== */

.site-header-actions {
    margin-top: 0.75rem;
}

.btn-submit-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.15rem;
    background: linear-gradient(135deg, var(--primary-color), #4f46e5);
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-submit-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    opacity: 0.95;
}

/* ==========================================================================
   連結卡片底部、投稿人與愛心點讚按鈕
   ========================================================================== */

.link-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.06);
    font-size: 0.825rem;
}

.link-author {
    color: #64748b;
    background: #f1f5f9;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.775rem;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-link-like {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.775rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-link-like:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #ef4444;
    transform: scale(1.06);
}

.btn-link-like.liked {
    background: #fef2f2;
    border-color: #f87171;
    color: #dc2626;
}

.btn-link-like.liked .like-heart {
    animation: heartPulse 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heartPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.45); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-3px); }
    40%, 80% { transform: translateX(3px); }
}

.animate-shake {
    animation: shake 0.35s ease-in-out;
}

/* ==========================================================================
   前台 Modal 通用樣式
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 1rem;
    box-sizing: border-box;
    pointer-events: none;
}

.modal-backdrop.open {
    display: flex !important;
    pointer-events: auto !important;
}

.modal-dialog {
    background: #ffffff;
    border-radius: 16px;
    max-width: 540px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 1.75rem;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.modal-backdrop.open .modal-dialog {
    transform: translateY(0);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.modal-head h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-modal-close {
    background: #f1f5f9;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #64748b;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-modal-close:hover {
    color: #0f172a;
    background: #e2e8f0;
    transform: rotate(90deg);
}

/* Modal 內表單元件排版與美化 */
.modal-dialog form {
    display: flex;
    flex-direction: column;
}

.modal-dialog .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 1.15rem;
    text-align: left;
}

.modal-dialog .form-group label {
    font-size: 0.92rem;
    font-weight: 600;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.modal-dialog .form-group label .required {
    color: #ef4444;
    font-weight: bold;
}

.modal-dialog .form-group input,
.modal-dialog .form-group select,
.modal-dialog .form-group textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #1e293b;
    background-color: #f8fafc;
    transition: all 0.2s ease;
    font-family: inherit;
}

.modal-dialog .form-group input:focus,
.modal-dialog .form-group select:focus,
.modal-dialog .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color, #2563eb);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.modal-dialog .form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.modal-dialog .form-hint {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.modal-dialog .form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
}

.modal-dialog .btn {
    padding: 0.65rem 1.35rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.modal-dialog .btn-primary {
    background: var(--primary-color, #2563eb);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.modal-dialog .btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.modal-dialog .btn-outline {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    color: #475569;
}

.modal-dialog .btn-outline:hover {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #94a3b8;
}

.modal-dialog .form-result {
    margin: 0.75rem 0 0 0;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-size: 0.88rem;
    line-height: 1.4;
    text-align: center;
    display: none;
}

.modal-dialog .form-result:not(:empty) {
    display: block;
}

.modal-dialog .form-result.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.modal-dialog .form-result.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ---------------------------------------------------------------- */
/* 前台首頁頂部右上角關鍵字即時搜尋列（精緻低調、貼齊邊緣）             */
/* ---------------------------------------------------------------- */

.top-corner-search {
    position: absolute;
    top: 0.75rem;
    right: 1.25rem;
    z-index: 60;
}

.header-search-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: rgba(248, 250, 252, 0.75);
    border: 1px solid rgba(203, 213, 225, 0.7);
    border-radius: 16px;
    padding: 0.2rem 0.55rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    width: 135px;
    opacity: 0.8;
}

.header-search-wrap:hover {
    opacity: 1;
    background: #ffffff;
    border-color: #cbd5e1;
    width: 170px;
}

.header-search-wrap:focus-within {
    opacity: 1;
    background: #ffffff;
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 2.5px rgba(37, 99, 235, 0.12), 0 2px 8px rgba(0, 0, 0, 0.05);
    width: 220px;
}

.header-search-icon {
    font-size: 0.82rem;
    color: #94a3b8;
    margin-right: 0.35rem;
    pointer-events: none;
    user-select: none;
    transition: color 0.2s ease;
}

.header-search-wrap:focus-within .header-search-icon {
    color: var(--primary-color, #2563eb);
}

.header-search-input {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 0.8rem;
    color: #334155;
    width: 100%;
    padding: 0.15rem 0 !important;
    margin: 0 !important;
}

.header-search-input::placeholder {
    color: #94a3b8;
    font-size: 0.78rem;
}

.header-search-input::-webkit-search-cancel-button {
    display: none;
}

.btn-clear-search {
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 0.65rem;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 0.3rem;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-clear-search:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.search-badge {
    background: #eff6ff;
    color: var(--primary-color, #2563eb);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.05rem 0.35rem;
    border-radius: 8px;
    margin-left: 0.3rem;
    white-space: nowrap;
    user-select: none;
}

@media (max-width: 640px) {
    .top-corner-search {
        position: static;
        display: flex;
        justify-content: flex-end;
        padding: 0.5rem 1rem 0;
    }
    .header-search-wrap {
        width: 100%;
        max-width: 100%;
        opacity: 1;
    }
    .header-search-wrap:hover,
    .header-search-wrap:focus-within {
        width: 100%;
    }
}

/* ==========================================================================
   獨立搜尋結果畫面 (Search Results Screen)
   ========================================================================== */

.search-results-screen {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 auto;
    min-height: 0;
}

.search-results-screen[hidden] {
    display: none !important;
}

.search-results-list {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    justify-content: center;
    margin: 0 auto;
}

.search-result-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
    position: relative;
}

.search-result-tab-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color, #2563eb);
    background-color: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    line-height: 1.3;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-no-results {
    padding: 3rem 1.5rem;
    color: var(--muted-color);
    text-align: center;
    font-size: 1rem;
    width: 100%;
    background: #f8fafc;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    margin: 1rem 0;
}

.search-results-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-search-back {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 2rem;
    border: 1.5px solid var(--primary-color, #2563eb);
    border-radius: 2rem;
    background-color: var(--surface-color, #ffffff);
    color: var(--primary-color, #2563eb);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.btn-search-back:hover {
    background-color: var(--primary-color, #2563eb);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

@media (max-width: 768px) {
    .search-results-screen {
        padding: 1rem 0.5rem;
    }
    .search-results-list {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }
}

/* ==========================================================================
   前台公告樣式 (Announcement Styles)
   ========================================================================== */

.announcement-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    font-size: 0.92rem;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.announcement-content {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1 1 auto;
}

.announcement-title {
    color: #0f172a;
}

.announcement-body {
    color: #334155;
}

.announcement-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #64748b;
    padding: 0.25rem;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s ease;
    flex-shrink: 0;
}

.announcement-close-btn:hover {
    color: #0f172a;
}

/* 1. 標準橫幅 (banner) */
.announcement-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid var(--primary-color, #2563eb);
}

/* 2. 重要提示框 (alert) */
.announcement-alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
}
.announcement-alert .announcement-title {
    color: #991b1b;
}

/* 3. 行內訊息 (inline) */
.announcement-inline {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #64748b;
}

/* 4. 跑馬燈 (marquee) */
.announcement-marquee {
    background: #fefce8;
    border: 1px solid #fef08a;
    border-left: 4px solid #eab308;
    overflow: hidden;
}

/* 5. 彈出對話框 (modal) */
.announcement-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.announcement-modal-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    max-width: 550px;
    width: 100%;
    padding: 1.5rem;
}

/* ==========================================================================
   前台動作按鈕 (cta-buttons)，cta-button-admin-crud 任務 5.1／5.2。
   三個版位（頁首／頁籤列旁／右下角固定懸浮層）共用同一份按鈕本體樣式，
   容器各自決定排列方式；懸浮層額外疊加固定定位。
   ========================================================================== */

.cta-button-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: var(--primary-color, #2563eb);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: filter 0.15s ease, transform 0.15s ease;
}

.cta-button-item:hover {
    filter: brightness(0.92);
    transform: translateY(-1px);
}

.header-cta-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tab-bar-cta-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.cta-floating-buttons {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    z-index: 9998;
}


