/* 
 * 軍警期別天梯網 V3 - 樣式表
 * Military & Police Academy Class Year Comparison Styles
 */

/* ========== CSS Variables ========== */
:root {
    --primary-color: #1a5f7a;
    --primary-dark: #0d3d4d;
    --primary-light: #2980b9;
    --accent-color: #c9a227;
    --accent-glow: rgba(201, 162, 39, 0.3);
    --bg-dark: #0a1628;
    --bg-card: #12263a;
    --bg-card-hover: #1a3a52;
    --text-primary: #ffffff;
    --text-secondary: #a8c5d8;
    --text-muted: #6b8a9e;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --historical-bg: #2d1f1a;
    --historical-border: #8b6914;
    --mainland-bg: #1a1a2e;
    --mainland-border: #c9302c;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Reset & Base ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0d1f3c 50%, var(--bg-dark) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ========== Background Pattern ========== */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(26, 95, 122, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(201, 162, 39, 0.08) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
}

/* ========== Container ========== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== Header ========== */
header {
    text-align: center;
    padding: 40px 20px 20px;
}

.logo {
    font-size: 3.5rem;
    margin-bottom: 15px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--accent-color);
    font-size: 1.1rem;
    font-weight: 500;
}

/* ========== Search Card ========== */
.search-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-soft);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 15px;
    margin-bottom: 20px;
}

label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
}

select,
input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition-fast);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a8c5d8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

select option,
select optgroup {
    background: var(--bg-dark);
    color: var(--text-primary);
}

input::placeholder {
    color: var(--text-muted);
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.2);
}

/* ========== Buttons ========== */
.btn-row {
    display: flex;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(41, 128, 185, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(41, 128, 185, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

/* ========== Results ========== */
#result-area {
    min-height: 50px;
}

.result-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.result-card.main-result {
    background: linear-gradient(135deg, rgba(26, 95, 122, 0.3) 0%, rgba(13, 61, 77, 0.3) 100%);
    border-color: var(--primary-color);
}

.result-card h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--accent-color);
}

.year-info {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.year-badge {
    background: rgba(201, 162, 39, 0.15);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 500;
}

.fun-fact {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

/* ========== Result Sections ========== */
.result-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.result-section h4 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.section-note {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 15px;
}

/* ========== Class Grid ========== */
.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.class-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 15px;
    text-align: center;
    transition: var(--transition-fast);
}

.class-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.class-card .school-name {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.class-card .class-number {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.class-card .country-flag {
    display: block;
    font-size: 1.2rem;
    margin-top: 8px;
}

.class-card.international {
    background: rgba(41, 128, 185, 0.1);
    border-color: rgba(41, 128, 185, 0.3);
}

.class-card.mainland {
    background: rgba(201, 48, 44, 0.1);
    border-color: rgba(201, 48, 44, 0.3);
}

/* ========== Historical Section ========== */
.historical-section {
    background: linear-gradient(135deg, var(--historical-bg) 0%, #1a1510 100%);
    border: 1px solid var(--historical-border);
}

.historical-section h4 {
    color: var(--accent-color);
}

.historical-grid {
    display: grid;
    gap: 15px;
}

.historical-card {
    background: rgba(139, 105, 20, 0.1);
    border: 1px solid rgba(139, 105, 20, 0.3);
    border-radius: var(--radius-sm);
    padding: 18px;
}

.historical-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.historical-header .school-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-color);
}

.historical-header .class-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.historical-msg {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.alumni {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========== Mainland Section ========== */
.mainland-section {
    background: linear-gradient(135deg, var(--mainland-bg) 0%, #16213e 100%);
    border: 1px solid rgba(201, 48, 44, 0.3);
}

/* ========== Error ========== */
.error {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 15px;
    border-radius: var(--radius-sm);
    text-align: center;
}

/* ========== Modal ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    color: var(--accent-color);
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

/* ========== Reference Table ========== */
.reference-table {
    width: 100%;
    border-collapse: collapse;
}

.reference-table th,
.reference-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.reference-table th {
    color: var(--accent-color);
    font-weight: 600;
    background: rgba(201, 162, 39, 0.1);
}

.reference-table td {
    color: var(--text-secondary);
}

.reference-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* --- FAQ 區塊（預設收合，不干擾工具主體） --- */
.faq-section { max-width: 720px; margin: 40px auto 20px; padding: 0 20px; }
.faq-heading { font-size: 1.1rem; font-weight: 600; color: var(--text-muted); cursor: pointer; padding: 12px 0; list-style: none; }
.faq-heading::before { content: '▸ '; }
details[open] > .faq-heading::before { content: '▾ '; }
.faq-list { margin-top: 12px; }
.faq-list details { border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 16px 20px; margin-bottom: 10px; background: var(--bg-card); }
.faq-list summary { font-weight: 600; cursor: pointer; font-size: 0.95rem; color: var(--text-primary); }
.faq-list details p { margin-top: 10px; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.7; }

/* ========== Footer ========== */
footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    header {
        padding: 30px 15px 15px;
    }

    .logo {
        font-size: 2.5rem;
    }

    h1 {
        font-size: 1.6rem;
    }

    .search-card {
        padding: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .btn-row {
        flex-direction: column;
    }

    .class-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .historical-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* ========== Animations ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-section {
    animation: fadeIn 0.3s ease;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}