/* CSS Variables - Design System */
:root {
    --primary-color: #0056b3;
    /* Professional Blue */
    --secondary-color: #003d82;
    /* Darker Blue */
    --accent-color: #0056b3;
    /* Accessible Blue for highlights (WCAG AA compliant) */
    --text-main: #333333;
    --text-light: #666666;
    --bg-main: #f8f9fa;
    /* Light gray for soft background */
    --bg-white: #ffffff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
}

/* Blocks and Elements (BEM Methodology) */

.header {
    background-color: var(--primary-color);
    color: var(--bg-white);
    padding: 3rem 0;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header__title {
    margin: 0;
    font-size: 2.5rem;
}

.header__subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

.nav {
    background-color: var(--secondary-color);
    padding: 1rem 0;
}

.nav__list {
    list-style-type: none;
    margin: 0;
    padding: 0;
    /* Module 03: Flexbox Container */
    display: flex;
    flex-direction: row;
    /* Default Main Axis */
    justify-content: center;
    /* Align along Main Axis */
    align-items: center;
    /* Align along Cross Axis */
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    gap: 2rem;
}

.nav__link {
    color: var(--bg-white);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s ease;
    padding: 0.5rem;
    /* Better click area */
}

.nav__link:hover {
    color: #ffde59;
}

.nav__link--active {
    color: #ffde59;
    border-bottom: 2px solid #ffde59;
}

/* Module 03: CSS Grid for Main Layout */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    /* 2 columns: 3fr for article, 1fr for sidebar (75% / 25% roughly) */
    grid-template-columns: 3fr 1fr;
    gap: 2rem;
}

/* Ensure child elements take up their grid areas */
/* .main-content__article is implicitly placed in column 1 */

.main-content__sidebar {
    /* Implicitly placed in column 2 */
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Module 03: CSS Grid for Feature Items */
.feature-grid {
    display: grid;
    /* Create responsive columns that fill the space, minimum 200px wide */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.feature-item {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: 6px;
    border-left: 4px solid var(--accent-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.feature-item__title {
    margin-top: 0;
    color: var(--secondary-color);
    font-size: 1.1rem;
}

.feature-item__desc {
    margin-bottom: 0;
    font-size: 0.95rem;
}

.card {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* For spacing if not in a grid/flex container */
    margin-bottom: 2rem;
}

.main-content__article .card:last-child {
    margin-bottom: 0;
}

.card--small {
    padding: 1.5rem;
    margin-bottom: 0;
    /* Override because sidebar uses flex gap */
}

.card__title {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-top: 0;
}

.card__text {
    line-height: 1.8;
}

.card__list {
    padding-left: 1.5rem;
    margin-bottom: 0;
}

.card__link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.card__link:hover {
    text-decoration: underline;
    color: var(--accent-color);
}

/* === CV Page Styles === */

/* Profile section: Flex container วางข้อมูลส่วนตัวและรูปโปรไฟล์เคียงกัน */
.cv-profile {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin: 1rem 0 2rem;
}

.cv-photo {
    margin: 0;
    flex-shrink: 0;
}

.cv-photo__img {
    width: 180px;
    height: 220px;
    object-fit: cover;
    border-radius: 8px;
    border: 3px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Definition List: ข้อมูลส่วนตัว - ใช้ Grid แบ่ง 2 คอลัมน์ (label : value) */
.cv-info {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 0.6rem 1.5rem;
    margin: 1rem 0 2rem;
    padding: 0;
}

.cv-info dt {
    font-weight: bold;
    color: var(--secondary-color);
}

.cv-info dd {
    margin: 0;
}

.cv-info dd a {
    color: #0046a0;
    text-decoration: none;
}

.cv-info dd a:hover {
    text-decoration: underline;
}

/* Table: การศึกษา */
.cv-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 2rem;
}

.cv-table th,
.cv-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.cv-table thead th {
    background-color: var(--primary-color);
    color: var(--bg-white);
    font-weight: 600;
}

.cv-table tbody tr:nth-child(even) {
    background-color: #f0f4f8;
}

.cv-table tbody tr:hover {
    background-color: #e2eaf3;
    transition: background-color 0.2s ease;
}

/* Unordered List: ทักษะ / งานอดิเรก */
.cv-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.cv-list li {
    padding: 0.5rem 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    background-color: #f0f4f8;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.cv-list li::before {
    content: "▸";
    position: absolute;
    left: 0.5rem;
    color: var(--accent-color);
    font-weight: bold;
}

.cv-list li:hover {
    background-color: #e2eaf3;
}

/* Blockquote: คติประจำใจ */
.cv-quote {
    margin: 1rem 0 2rem;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid var(--accent-color);
    background-color: #f0f4f8;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--text-light);
}

.cv-quote p {
    margin: 0;
    font-size: 1.1rem;
}

/* Ordered List: เป้าหมาย */
.cv-goals {
    margin: 1rem 0 0;
    padding-left: 1.5rem;
}

.cv-goals li {
    padding: 0.5rem 0;
    border-bottom: 1px dashed #e0e0e0;
}

.cv-goals li:last-child {
    border-bottom: none;
}

/* CV Page: h3 section titles */
.card__content h3 {
    color: var(--secondary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.4rem;
}

.card__content h3:first-child {
    margin-top: 0;
}

/* =============================================
   Responsive Design - Media Queries ทุกหน้า
   ============================================= */

/* --- Tablet (max-width: 1024px) --- */
@media (max-width: 1024px) {

    /* เปลี่ยนเป็น 1 คอลัมน์เมื่อหน้าจอไม่กว้างพอ */
    .main-content {
        grid-template-columns: 1fr;
    }

    /* Sidebar ย้ายลงล่าง → วาง card แนวนอน */
    .main-content__sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .main-content__sidebar .card--small {
        flex: 1 1 200px;
    }
}

/* --- Mobile / Tablet เล็ก (max-width: 768px) --- */
@media (max-width: 768px) {

    /* Header: ลดขนาด */
    .header {
        padding: 2rem 1rem;
    }

    .header__title {
        font-size: 2rem;
    }

    .header__subtitle {
        font-size: 1rem;
    }

    /* Nav: gap แคบลง */
    .nav__list {
        gap: 0.75rem 1.25rem;
    }

    /* Main Content: padding ลด */
    .main-content {
        grid-template-columns: 1fr;
        padding: 0 0.75rem;
        margin: 1.5rem auto;
    }

    /* Card: padding ลด */
    .card {
        padding: 1.5rem;
    }

    /* Feature Grid: stack เป็น 1 คอลัมน์ */
    .feature-grid {
        grid-template-columns: 1fr;
    }

    /* CV Profile: stack แนวตั้ง + center */
    .cv-profile {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .cv-photo__img {
        width: 150px;
        height: 190px;
    }

    /* CV Info: 1 คอลัมน์ */
    .cv-info {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .cv-info dt {
        margin-top: 0.5rem;
    }

    /* CV Table: font ลด */
    .cv-table {
        font-size: 0.85rem;
    }

    .cv-table th,
    .cv-table td {
        padding: 0.5rem;
    }

    /* CV List: 1 คอลัมน์ */
    .cv-list {
        grid-template-columns: 1fr;
    }

    /* Sidebar: stack กลับเป็นแนวตั้ง */
    .main-content__sidebar {
        flex-direction: column;
    }

    /* Footer: ลด padding */
    .footer {
        padding: 1.5rem 1rem;
        margin-top: 2rem;
    }
}

/* --- มือถือเล็ก (max-width: 480px) --- */
@media (max-width: 480px) {

    /* Header: ขนาดกะทัดรัด */
    .header {
        padding: 1.5rem 0.75rem;
    }

    .header__title {
        font-size: 1.6rem;
    }

    .header__subtitle {
        font-size: 0.9rem;
    }

    /* Nav: แคบลงอีก */
    .nav {
        padding: 0.75rem 0;
    }

    .nav__list {
        gap: 0.4rem 0.75rem;
    }

    .nav__link {
        font-size: 0.85rem;
        padding: 0.35rem;
    }

    /* Card: padding แคบสุด */
    .card {
        padding: 1.25rem;
        margin-bottom: 1.25rem;
    }

    .card__title {
        font-size: 1.15rem;
    }

    /* Feature Item: padding ลด */
    .feature-item {
        padding: 1rem;
    }

    .feature-item__title {
        font-size: 1rem;
    }

    .feature-item__desc {
        font-size: 0.85rem;
    }

    /* CV Photo: ย่อลงอีก */
    .cv-photo__img {
        width: 120px;
        height: 155px;
    }

    /* CV Quote: font ลด */
    .cv-quote p {
        font-size: 1rem;
    }

    /* Footer */
    .footer {
        padding: 1.25rem 0.75rem;
    }

    .footer__text {
        font-size: 0.85rem;
    }
}

/* === Footer === */

.footer {
    background-color: var(--text-main);
    color: var(--bg-white);
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer__text {
    margin: 0;
}