/* =========================================================
   CanCham Cambodia - Main Site Styles
   File: /assets/css/main.css
   ========================================================= */

/* ---------- CSS Variables ---------- */
:root {
    --color-bg: #f4f7fb;
    --color-surface: #ffffff;
    --color-surface-soft: #f8fbff;
    --color-surface-muted: #eef3f8;

    --color-text: #182538;
    --color-text-muted: #5f6f86;
    --color-heading: #0f1c2d;

    --color-primary: #0f4c81;
    --color-primary-strong: #0b3b64;
    --color-primary-soft: #dcecff;
    --color-secondary: #1d6fa3;
    --color-accent: #d9ebfa;

    --color-border: rgba(24, 37, 56, 0.1);
    --color-border-strong: rgba(24, 37, 56, 0.18);

    --color-success: #1d7a52;
    --color-warning: #b7791f;
    --color-danger: #b53a3a;

    --shadow-sm: 0 8px 24px rgba(12, 28, 52, 0.06);
    --shadow-md: 0 16px 42px rgba(12, 28, 52, 0.1);
    --shadow-lg: 0 24px 70px rgba(12, 28, 52, 0.14);

    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 26px;
    --radius-xl: 34px;
    --radius-pill: 999px;

    --container-width: 1240px;
    --site-gutter: 1.25rem;

    --font-sans:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;

    --transition-fast: 0.2s ease;
    --transition-medium: 0.28s ease;

    --header-height: 82px;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
    margin: 0;
}

ul[role="list"],
ol[role="list"] {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul,
ol {
    padding-left: 1.25rem;
}

img,
picture,
svg,
canvas {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

input,
button,
textarea,
select {
    font: inherit;
}

button,
input,
select,
textarea {
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    border: 0;
    background: none;
    cursor: pointer;
}

table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}

/* ---------- Base ---------- */
html,
body {
    min-height: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background:
        radial-gradient(circle at top left, rgba(15, 76, 129, 0.05), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, var(--color-bg) 100%);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: rgba(15, 76, 129, 0.16);
    color: var(--color-heading);
}

:focus-visible {
    outline: 3px solid rgba(15, 76, 129, 0.28);
    outline-offset: 3px;
    border-radius: 6px;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--color-heading);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

h1 {
    font-size: clamp(2.4rem, 5vw, 4.5rem);
}

h2 {
    font-size: clamp(1.9rem, 3vw, 3rem);
}

h3 {
    font-size: clamp(1.25rem, 2vw, 1.75rem);
}

h4 {
    font-size: 1.125rem;
}

p {
    color: var(--color-text);
}

strong {
    font-weight: 700;
}

small {
    font-size: 0.875rem;
}

/* ---------- Layout ---------- */
.site-shell {
    width: min(100% - (var(--site-gutter) * 2), var(--container-width));
    margin-inline: auto;
}

.page {
    min-height: 100vh;
}

.page-main {
    display: block;
}

.section {
    padding: clamp(4rem, 7vw, 7rem) 0;
}

/* ---------- Utility ---------- */
.visually-hidden,
.sr-only {
    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: 0 !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-text-muted);
}

.flow > * + * {
    margin-top: 1rem;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.78);
    border-bottom: 1px solid rgba(24, 37, 56, 0.08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.site-header__inner {
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-header__brand-wrap {
    min-width: 0;
    flex: 0 1 auto;
}

.site-header__brand {
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.25rem 0;
}

.site-header__brand-title {
    color: var(--color-heading);
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.site-header__brand-tagline {
    color: var(--color-text-muted);
    font-size: 0.78rem;
    line-height: 1.2;
}

.site-header__nav {
    flex: 0 1 auto;
}

.site-header__nav-list {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-header__nav-item {
    margin: 0;
}

.site-header__nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-pill);
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: 0.95rem;
    transition:
        color var(--transition-fast),
        background-color var(--transition-fast),
        transform var(--transition-fast);
}

.site-header__nav-link:hover,
.site-header__nav-link:focus-visible {
    color: var(--color-primary-strong);
    background: rgba(15, 76, 129, 0.06);
}

.site-header__nav-link.is-active,
.site-header__nav-link[aria-current="page"] {
    color: var(--color-primary-strong);
    background: linear-gradient(180deg, rgba(15, 76, 129, 0.11), rgba(15, 76, 129, 0.08));
    box-shadow: inset 0 0 0 1px rgba(15, 76, 129, 0.1);
}

/* ---------- Buttons ---------- */
.button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 3.1rem;
    padding: 0.85rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.96rem;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    transition:
        transform var(--transition-medium),
        box-shadow var(--transition-medium),
        background-color var(--transition-medium),
        color var(--transition-medium),
        border-color var(--transition-medium);
    will-change: transform;
}

.button:hover,
.button:focus-visible {
    transform: translateY(-2px);
}

.button-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(15, 76, 129, 0.22);
}

.button-primary:hover,
.button-primary:focus-visible {
    box-shadow: 0 18px 36px rgba(15, 76, 129, 0.28);
}

.button-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-primary-strong);
    border-color: rgba(15, 76, 129, 0.12);
    box-shadow: var(--shadow-sm);
}

.button-secondary:hover,
.button-secondary:focus-visible {
    background: #ffffff;
    border-color: rgba(15, 76, 129, 0.2);
}

.button-ghost {
    background: transparent;
    color: var(--color-primary);
    border-color: rgba(15, 76, 129, 0.14);
}

.button-ghost:hover,
.button-ghost:focus-visible {
    background: rgba(15, 76, 129, 0.05);
}

/* ---------- Links ---------- */
.text-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--color-primary);
    font-weight: 700;
    transition: color var(--transition-fast);
}

.text-link:hover,
.text-link:focus-visible {
    color: var(--color-primary-strong);
}

.text-link::after {
    content: "→";
    transition: transform var(--transition-fast);
}

.text-link:hover::after,
.text-link:focus-visible::after {
    transform: translateX(3px);
}

/* ---------- Cards ---------- */
.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.86));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-body {
    padding: 1.5rem;
}

/* ---------- Forms ---------- */
label {
    display: inline-block;
    margin-bottom: 0.45rem;
    color: var(--color-heading);
    font-weight: 700;
    font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 3.2rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(24, 37, 56, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--color-text);
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background-color var(--transition-fast);
}

textarea {
    min-height: 8rem;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #8a96a8;
}

input:hover,
select:hover,
textarea:hover {
    border-color: rgba(15, 76, 129, 0.18);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(15, 76, 129, 0.45);
    box-shadow: 0 0 0 4px rgba(15, 76, 129, 0.12);
    background: #ffffff;
}

/* ---------- Content defaults ---------- */
main a:not(.button):not(.text-link):not(.site-header__brand):not(.site-header__nav-link) {
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.12em;
}

main a:not(.button):not(.text-link):not(.site-header__brand):not(.site-header__nav-link):hover,
main a:not(.button):not(.text-link):not(.site-header__brand):not(.site-header__nav-link):focus-visible {
    color: var(--color-primary-strong);
}

blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-left: 4px solid rgba(15, 76, 129, 0.22);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--color-surface-soft);
    color: var(--color-text-muted);
}

hr {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

/* ---------- Footer ---------- */
.site-footer {
    margin-top: 0;
    border-top: 1px solid rgba(24, 37, 56, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.9));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.site-footer__text {
    padding: 1.5rem 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    text-align: center;
}

/* ---------- Tables ---------- */
table {
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

th,
td {
    padding: 0.95rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(24, 37, 56, 0.08);
}

th {
    color: var(--color-heading);
    font-weight: 800;
    background: var(--color-surface-soft);
}

tr:last-child td {
    border-bottom: 0;
}

/* ---------- Fallback helper classes ---------- */
.site-header-fallback,
.site-footer-fallback {
    width: 100%;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    :root {
        --header-height: 74px;
    }

    .site-header__inner {
        flex-wrap: wrap;
        padding: 0.7rem 0;
    }

    .site-header__nav {
        width: 100%;
    }

    .site-header__nav-list {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    :root {
        --site-gutter: 0.9rem;
    }

    body {
        font-size: 15.5px;
    }

    .site-header {
        position: sticky;
    }

    .site-header__inner {
        align-items: flex-start;
        gap: 0.8rem;
    }

    .site-header__brand {
        max-width: 100%;
    }

    .site-header__brand-title {
        font-size: 1rem;
    }

    .site-header__brand-tagline {
        font-size: 0.72rem;
    }

    .site-header__nav-list {
        gap: 0.4rem;
    }

    .site-header__nav-link {
        min-height: 2.55rem;
        padding: 0.65rem 0.9rem;
        font-size: 0.92rem;
    }

    .button {
        min-height: 3rem;
        padding: 0.85rem 1.05rem;
        white-space: normal;
    }

    .card-body {
        padding: 1.2rem;
    }

    th,
    td {
        padding: 0.8rem 0.85rem;
    }
}

@media (max-width: 520px) {
    .site-header__inner {
        min-height: auto;
    }

    .site-header__nav-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .site-header__nav-link {
        width: 100%;
    }

    .site-footer__text {
        padding: 1.2rem 0;
        font-size: 0.9rem;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .button:hover,
    .button:focus-visible {
        transform: none;
    }
}