/* ── Design Tokens ── */
:root {
    --bg: #FAFAF8;
    --bg-alt: #F3F3EF;
    --text: #2C2C2C;
    --text-muted: #6B6B6B;
    --accent: #5B7C6B;
    --accent-hover: #4A6B5A;
    --accent-light: #E8F0EC;
    --border: #E8E8E4;
    --white: #FFFFFF;
    --shadow: 0 2px 12px rgba(44, 44, 44, 0.06);
    --shadow-hover: 0 6px 24px rgba(44, 44, 44, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --header-h: 64px;
    --max-w: 960px;
    --font: "Noto Sans TC", -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.25s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

ul { list-style: none; }

/* ── Layout ── */
.container {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
}

.section {
    padding: 96px 0;
}

.section-alt {
    position: relative;
    background: var(--bg-alt);
    overflow: hidden;
}

.section-alt::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('../images/section-bg.jpg') center / cover no-repeat;
    opacity: 0.07;
    pointer-events: none;
}

.section-alt > .container {
    position: relative;
    z-index: 1;
}

.section-label {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
}

.section-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 16px;
}

.section-desc {
    color: var(--text-muted);
    max-width: 560px;
    margin-bottom: 48px;
}

/* ── Header ── */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-h);
    background: rgba(250, 250, 248, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.site-header.scrolled {
    border-bottom-color: var(--border);
    box-shadow: var(--shadow);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.logo:hover { color: var(--accent); }

.site-nav {
    display: flex;
    gap: 8px;
}

.site-nav a {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.site-nav a:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
}

.nav-toggle svg {
    width: 24px;
    height: 24px;
}

/* ── Hero ── */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: var(--header-h);
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('../images/hero-bg.jpg') center / cover no-repeat;
    transform: scale(1.03);
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        120deg,
        rgba(250, 250, 248, 0.94) 0%,
        rgba(250, 250, 248, 0.86) 45%,
        rgba(232, 240, 236, 0.90) 100%
    );
}

.hero > .container {
    position: relative;
    z-index: 1;
}

.hero-content {
    max-width: 640px;
}

.hero-greeting {
    font-size: 0.9375rem;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 16px;
}

.hero-title {
    font-size: clamp(2.25rem, 5vw, 3.25rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: 20px;
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--text-muted);
    margin-bottom: 40px;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--white);
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ── About ── */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: start;
}

.about-text p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.about-text p:last-child { margin-bottom: 0; }

.about-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ── Services ── */
.services-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.service-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    transition: box-shadow var(--transition), transform var(--transition);
}

.service-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
}

.service-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--accent);
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}

.service-icon svg {
    width: 22px;
    height: 22px;
}

.service-card:hover .service-icon {
    background: var(--accent);
    color: var(--white);
}

.service-card h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.service-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.65;
}

/* ── Skills ── */
.skills-groups {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
}

.skill-group h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.skill-tag {
    display: inline-block;
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 100px;
    transition: border-color var(--transition), background var(--transition);
}

.skill-tag:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

/* ── Resume Timeline ── */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 40px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
    content: "";
    position: absolute;
    left: -28px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--accent);
}

.timeline-period {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 6px;
}

.timeline-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.timeline-org {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.timeline-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.65;
}

.timeline-desc li {
    position: relative;
    padding-left: 16px;
    margin-bottom: 4px;
}

.timeline-desc li::before {
    content: "·";
    position: absolute;
    left: 4px;
    color: var(--accent);
}

/* ── Portfolio ── */
.portfolio-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--accent-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--accent-hover);
    margin-bottom: 32px;
    max-width: 560px;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.portfolio-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

.portfolio-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
}

.portfolio-thumb {
    height: 160px;
    background: var(--bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: var(--border);
    letter-spacing: -0.02em;
    border-bottom: 1px solid var(--border);
}

.portfolio-body {
    padding: 20px;
}

.portfolio-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-light);
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.portfolio-body h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.portfolio-body p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 14px;
}

.portfolio-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.portfolio-tags span {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 4px;
}

.portfolio-link {
    font-size: 0.8125rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.portfolio-link::after {
    content: "→";
    transition: transform var(--transition);
}

.portfolio-link:hover::after {
    transform: translateX(3px);
}

/* ── Contact ── */
#contact.section-alt::before {
    background-image: url('../images/contact-bg.jpg');
    opacity: 0.13;
}

.contact-action {
    margin-top: 8px;
}

.contact-note {
    margin-top: 20px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

body.modal-open {
    overflow: hidden;
}

.contact-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.contact-modal[hidden] {
    display: none;
}

.contact-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(44, 44, 44, 0.45);
    backdrop-filter: blur(2px);
}

.contact-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 560px;
    max-height: min(92vh, 860px);
    overflow: auto;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 28px 24px 24px;
}

.contact-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.contact-modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.contact-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.contact-modal-close:hover {
    color: var(--text);
    background: var(--bg-alt);
}

.contact-modal-body {
    min-height: 120px;
}

.contact-modal-body.is-success {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-field label,
.form-field legend {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

fieldset.form-field,
.form-field fieldset {
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.form-field legend {
    margin-bottom: 10px;
    padding: 0;
    float: none;
    width: auto;
}

.radio-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    border: none;
    padding: 0;
    margin: 0;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field select,
.form-field textarea {
    width: 100%;
    font-family: var(--font);
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-field textarea {
    min-height: 120px;
    resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(91, 124, 107, 0.15);
}

.form-hint {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    cursor: pointer;
    transition: color var(--transition);
}

.radio-option:has(input:checked) {
    color: var(--accent);
    font-weight: 500;
}

.radio-option input {
    accent-color: var(--accent);
}

.captcha-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.captcha-row input {
    flex: 1;
    min-width: 0;
}

.captcha-row img {
    width: 120px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-alt);
    flex-shrink: 0;
}

.form-error {
    font-size: 0.875rem;
    color: #b42318;
    background: #fef3f2;
    border: 1px solid #fecdca;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.contact-success {
    text-align: center;
    padding: 24px 12px;
    width: 100%;
}

.contact-success[hidden] {
    display: none !important;
}

.contact-form[hidden] {
    display: none !important;
}

.contact-success p {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.contact-success small {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.contact-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.contact-form-actions .btn {
    min-width: 96px;
}

/* ── Footer ── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ── Scroll reveal ── */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .section { padding: 72px 0; }

    .nav-toggle { display: block; }

    .site-nav {
        display: none;
        position: absolute;
        top: var(--header-h);
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        padding: 12px 16px 20px;
        box-shadow: var(--shadow);
    }

    .site-nav.open { display: flex; }

    .site-nav a {
        padding: 10px 12px;
        font-size: 1rem;
    }

    .about-grid,
    .services-grid,
    .skills-groups,
    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .radio-group {
        grid-template-columns: 1fr;
    }

    .contact-modal-panel {
        padding: 22px 16px 18px;
    }

    .about-stats {
        grid-template-columns: 1fr 1fr;
    }

    .hero { min-height: auto; padding: calc(var(--header-h) + 64px) 0 80px; }
}

@media (max-width: 480px) {
    .about-stats { grid-template-columns: 1fr; }
    .hero-actions { flex-direction: column; }
    .btn { justify-content: center; }
}
