﻿/* ===================================
   Site_error.master 專用樣式
   Bootstrap 5 + 無障礙 AA 等級
   =================================== */

/* === 全域重置 === */
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100%;
    margin: 0;
    padding: 0;
    font-family: "Microsoft JhengHei", "微軟正黑體", "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe6e6 100%);
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Firefox Android 字體大小修正 */
@-moz-document url-prefix() {
    body {
        -moz-text-size-adjust: 100%;
    }
}

/* === 無障礙：跳到主要內容連結 === */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 10000;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #ffbf47;
    outline-offset: 0;
}

/* === 錯誤頁面容器 === */
.error-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* === 頭部區域 === */
.error-header {
    background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2);
    position: relative;
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0;
}

.header-logo {
    flex-shrink: 0;
}

.logo-img {
    max-height: 60px;
    width: auto;
    display: block;
}

.header-title {
    flex: 1;
}

.site-title {
    margin: 0;
    font-size: 1.5rem; /* 24px */
    font-weight: 700;
    line-height: 1.3;
    color: white;
}

.site-subtitle {
    display: block;
    font-size: 1rem; /* 16px */
    font-weight: 400;
    margin-top: 0.25rem;
    opacity: 0.95;
}

/* === 公告欄（黃色警告） === */
.notice-bar {
    background-color: #fff3cd;
    border-bottom: 2px solid #ffc107;
    min-height: 50px;
    display: flex;
    align-items: center;
}

.notice-content {
    padding: 0.75rem 0;
    text-align: center;
    color: #856404;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.notice-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.notice-text {
    font-size: 1.125rem; /* 18px */
}

/* === 主要內容區 === */
.error-main {
    flex: 1;
    padding: 3rem 1rem;
    display: flex;
    align-items: center;
}

.error-content {
    background: white;
    border-radius: 12px;
    padding: 3rem 2rem;
    box-shadow: 0 8px 24px rgba(220, 53, 69, 0.15);
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    border: 2px solid #f8d7da;
}

/* === 錯誤圖片 === */
.error-image-container {
    margin-bottom: 2rem;
}

.error-image {
    max-width: 100%;
    height: auto;
    max-height: 411px;
    width: auto;
    display: inline-block;
    animation: fadeInScale 0.6s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* === 錯誤訊息區 === */
.error-message-section {
    color: #333;
    font-size: 1.125rem; /* 18px */
    line-height: 1.8;
}

.error-message-section h2 {
    color: #dc3545;
    font-size: 2rem; /* 32px */
    font-weight: 700;
    margin-bottom: 1rem;
    margin-top: 0;
}

.error-message-section h3 {
    color: #333;
    font-size: 1.5rem; /* 24px */
    font-weight: 600;
    margin-bottom: 1rem;
}

.error-message-section p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.error-message-section a {
    color: #dc3545;
    text-decoration: none;
    font-weight: 600;
}

.error-message-section a:hover {
    color: #b02a37;
    text-decoration: underline;
}

.error-message-section a:focus {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

/* === 錯誤操作按鈕樣式 === */
.btn-error-primary {
    background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%);
    border: none;
    color: white;
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    padding: 0.875rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
    min-height: 50px;
    line-height: 1.5;
    margin: 0.5rem;
}

.btn-error-primary:hover {
    background: linear-gradient(135deg, #b02a37 0%, #8e1f2e 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.4);
    color: white;
}

.btn-error-primary:focus {
    outline: 3px solid #ffbf47;
    outline-offset: 3px;
}

.btn-error-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
    border: none;
    color: white;
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    padding: 0.875rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
    min-height: 50px;
    line-height: 1.5;
    margin: 0.5rem;
}

.btn-error-secondary:hover {
    background: linear-gradient(135deg, #545b62 0%, #3d4349 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(108, 117, 125, 0.4);
    color: white;
}

.btn-error-secondary:focus {
    outline: 3px solid #ffbf47;
    outline-offset: 3px;
}

/* === 頁尾區域 === */
.error-footer {
    background-color: #2c2c2c;
    color: #fff;
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-content {
    font-size: 0.9375rem; /* 15px */
    line-height: 1.6;
}

.footer-link {
    color: #ffc107;
    text-decoration: none;
    font-weight: 600;
}

.footer-link:hover {
    color: #ffb300;
    text-decoration: underline;
}

.footer-link:focus {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

/* === 響應式設計 === */

/* 平板 (≤ 991px) */
@media (max-width: 991.98px) {
    .site-title {
        font-size: 1.25rem; /* 20px */
    }
    
    .site-subtitle {
        font-size: 0.9375rem; /* 15px */
    }
    
    .error-content {
        padding: 2rem 1.5rem;
    }
    
    .error-image {
        max-height: 350px;
    }
    
    .error-message-section h2 {
        font-size: 1.75rem; /* 28px */
    }
    
    .notice-text {
        font-size: 1rem; /* 16px */
    }
}

/* 手機 (≤ 767px) */
@media (max-width: 767.98px) {
    
    body {
        font-size: 14px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem 0;
        gap: 0.75rem;
    }
    
    .logo-img {
        max-height: 50px;
    }
    
    .site-title {
        font-size: 1.125rem; /* 18px */
    }
    
    .site-subtitle {
        font-size: 0.875rem; /* 14px */
    }
    
    .notice-bar {
        min-height: 45px;
    }
    
    .notice-content {
        padding: 0.5rem 0;
    }
    
    .notice-icon {
        font-size: 1.25rem;
    }
    
    .notice-text {
        font-size: 0.9375rem; /* 15px */
    }
    
    .error-main {
        padding: 2rem 0.75rem;
    }
    
    .error-content {
        padding: 2rem 1rem;
        border-radius: 8px;
    }
    
    .error-image {
        max-height: 280px;
    }
    
    .error-message-section {
        font-size: 1rem; /* 16px */
    }
    
    .error-message-section h2 {
        font-size: 1.5rem; /* 24px */
    }
    
    .error-message-section h3 {
        font-size: 1.25rem; /* 20px */
    }
    
    .btn-error-primary,
    .btn-error-secondary {
        width: 100%;
        font-size: 1rem; /* 16px */
        padding: 0.75rem 1.5rem;
        justify-content: center;
        margin: 0.5rem 0;
    }
    
    .error-footer {
        padding: 1rem 0;
    }
    
    .footer-content {
        font-size: 0.875rem; /* 14px */
    }
}

/* 小手機 (≤ 575px) */
@media (max-width: 575.98px) {
    
    body {
        font-size: 13px;
    }
    
    .logo-img {
        max-height: 40px;
    }
    
    .site-title {
        font-size: 1rem; /* 16px */
    }
    
    .site-subtitle {
        font-size: 0.8125rem; /* 13px */
    }
    
    .notice-icon {
        font-size: 1rem;
    }
    
    .notice-text {
        font-size: 0.875rem; /* 14px */
    }
    
    .error-content {
        padding: 1.5rem 0.75rem;
    }
    
    .error-image {
        max-height: 220px;
    }
    
    .error-message-section {
        font-size: 0.9375rem; /* 15px */
    }
    
    .error-message-section h2 {
        font-size: 1.25rem; /* 20px */
    }
    
    .error-message-section h3 {
        font-size: 1.125rem; /* 18px */
    }
    
    .btn-error-primary,
    .btn-error-secondary {
        font-size: 0.9375rem; /* 15px */
        padding: 0.75rem 1.25rem;
    }
    
    .footer-content {
        font-size: 0.8125rem; /* 13px */
    }
}

/* === 無障礙樣式 === */

/* 焦點指示器 */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

/* 移除非鍵盤操作的焦點樣式 */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

/* 鍵盤操作時顯示焦點 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

/* 螢幕閱讀器專用 */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border-width: 0 !important;
}

/* === 列印樣式 === */
@media print {
    .error-header,
    .notice-bar,
    .error-footer,
    .skip-link {
        display: none;
    }
    
    .error-main {
        padding: 0;
    }
    
    .error-content {
        box-shadow: none;
        border-radius: 0;
        border: 2px solid #000;
    }
    
    body {
        background: white;
    }
}

/* === 高對比模式 === */
@media (prefers-contrast: high) {
    .error-header {
        border-bottom: 3px solid #000;
    }
    
    .error-content {
        border: 3px solid #000;
    }
    
    a {
        text-decoration: underline;
    }
}

/* === 減少動畫 === */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
    
    .btn-error-primary:hover,
    .btn-error-secondary:hover {
        transform: none;
    }
}

/* === 容器最大寬度調整 === */
@media (min-width: 1400px) {
    .container-fluid {
        max-width: 1320px;
        margin: 0 auto;
    }
}

/* === 輔助類別 === */
.text-error {
    color: #dc3545 !important;
}

.bg-error {
    background-color: #dc3545 !important;
}

/* === 舊版相容性 === */
.page,
.header,
.main,
.footer,
.clear {
    /* 保留舊的 class 以防其他頁面使用 */
}
