/* =============================================================
   Mahmoud Shaabo Portfolio — Stylesheet
   Dark/light themes, EN/AR (LTR/RTL), reduced-motion safe.
   ============================================================= */

/* ---------- Shared design tokens (non-color) ---------- */
:root {
    --font-en: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --font-ar: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    --font-base: var(--font-en);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Design tokens (dark theme) ---------- */
:root[data-theme="dark"],
html.theme-dark {
    --bg-main: #0d1117;
    --bg-section: #161b22;
    --bg-card: #21262d;
    --bg-elevated: #1c2128;
    --border-color: #30363d;
    --border-strong: #484f58;

    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent: #f08a24;
    --accent-hover: #ff9e42;
    --accent-soft: rgba(240, 138, 36, 0.15);
    --accent-glow: rgba(240, 138, 36, 0.25);

    --success: #2ea44f;
    --danger: #f85149;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);

    color-scheme: dark;
}

/* ---------- Light theme overrides ---------- */
:root[data-theme="light"],
html.theme-light {
    --bg-main: #f6f8fa;
    --bg-section: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --border-color: #d0d7de;
    --border-strong: #afb8c1;

    --text-primary: #1f2328;
    --text-secondary: #59636e;
    --text-muted: #6e7781;

    --accent: #9a4d00;
    --accent-hover: #773b00;
    --accent-soft: rgba(154, 77, 0, 0.12);
    --accent-glow: rgba(154, 77, 0, 0.25);

    --success: #1a7f37;
    --danger: #cf222e;

    --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.08);
    --shadow-md: 0 8px 24px rgba(31, 35, 40, 0.10);
    --shadow-lg: 0 20px 50px rgba(31, 35, 40, 0.12);

    color-scheme: light;
}

/* Use Cairo as primary font when document language is Arabic */
:root[lang="ar"] {
    --font-base: var(--font-ar);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    scroll-padding-top: 90px; /* offset for sticky header */
    background-color: var(--bg-main, #0d1117);
    color: var(--text-primary, #f0f6fc);
}

/* Explicit theme colors (fallback if CSS variables are blocked) */
html[data-theme="light"],
html.theme-light {
    color-scheme: light;
    background-color: #f6f8fa;
    color: #1f2328;
}

html[data-theme="dark"],
html.theme-dark {
    color-scheme: dark;
    background-color: #0d1117;
    color: #f0f6fc;
}

html[data-theme="light"] body,
html.theme-light body {
    background-color: #f6f8fa;
    color: #1f2328;
}

html[data-theme="dark"] body,
html.theme-dark body {
    background-color: #0d1117;
    color: #f0f6fc;
}

html[data-theme="light"] .about-section,
html[data-theme="light"] .projects-section,
html.theme-light .about-section,
html.theme-light .projects-section {
    background-color: #ffffff;
}

html[data-theme="dark"] .about-section,
html[data-theme="dark"] .projects-section,
html.theme-dark .about-section,
html.theme-dark .projects-section {
    background-color: #161b22;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-base);
    line-height: 1.75;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-slow), color var(--transition-slow);
    overflow-x: hidden;
}

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

button {
    font: inherit;
    cursor: pointer;
    background: none;
    border: none;
    color: inherit;
}

/* ---------- Focus styles ---------- */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ---------- Screen-reader-only utility ---------- */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Skip link ---------- */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #0d1117;
    padding: 12px 22px;
    font-weight: 700;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    z-index: 9999;
    transition: top var(--transition);
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* Forced-colors / High Contrast notice */
.forced-colors-notice {
    display: none;
    margin: 0;
    padding: 10px 16px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
    background-color: var(--accent-soft);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

/* ---------- Container ---------- */
.container {
    width: 92%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ============================================================= */
/*                            HEADER                              */
/* ============================================================= */

.main-header {
    background-color: color-mix(in srgb, var(--bg-main) 85%, transparent);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    height: 76px;
}

.logo a {
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: 0.5px;
    transition: color var(--transition);
    font-family: var(--font-en);
}

:root[lang="ar"] .logo a {
    font-family: var(--font-ar);
}

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

/* Primary nav */
.main-nav ul {
    display: flex;
    list-style: none;
    gap: 8px;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.98rem;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    transition: color var(--transition), background-color var(--transition);
    position: relative;
}

.main-nav a:hover {
    color: var(--text-primary);
    background-color: var(--bg-card);
}

.main-nav a[aria-current="true"] {
    color: var(--accent);
    background-color: var(--accent-soft);
}

/* Header action buttons */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: color var(--transition), background-color var(--transition), border-color var(--transition);
    font-weight: 700;
    font-size: 0.85rem;
    font-family: var(--font-en);
}

.icon-btn:hover {
    color: var(--accent);
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

.icon-btn .icon {
    width: 20px;
    height: 20px;
}

/* Theme toggle button with visible label */
.theme-toggle-btn {
    width: auto;
    min-width: 40px;
    padding: 0 12px;
    gap: 8px;
    font-family: var(--font-en);
}

.theme-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle-text {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* Theme toggle icon swap */
#theme-toggle .icon-moon { display: none; }
#theme-toggle .icon-sun  { display: block; }
html[data-theme="light"] #theme-toggle .icon-moon,
html.theme-light #theme-toggle .icon-moon { display: block; }
html[data-theme="light"] #theme-toggle .icon-sun,
html.theme-light #theme-toggle .icon-sun  { display: none; }

/* Hamburger */
.menu-toggle {
    display: none;
}

.menu-bars {
    position: relative;
    width: 22px;
    height: 2px;
    background: currentColor;
    transition: background var(--transition);
}

.menu-bars::before,
.menu-bars::after {
    content: '';
    position: absolute;
    left: 0;
    width: 22px;
    height: 2px;
    background: currentColor;
    transition: transform var(--transition), top var(--transition);
}

.menu-bars::before { top: -7px; }
.menu-bars::after  { top:  7px; }

.menu-toggle[aria-expanded="true"] .menu-bars { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-bars::before { top: 0; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-bars::after  { top: 0; transform: rotate(-45deg); }

/* ============================================================= */
/*                             HERO                               */
/* ============================================================= */

.hero-section {
    position: relative;
    padding: 90px 0 100px;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
}

.hero-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(600px circle at 20% 20%, var(--accent-soft), transparent 60%),
        radial-gradient(500px circle at 80% 80%, var(--accent-glow), transparent 70%);
    opacity: 0.6;
}

.hero-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 70px;
}

.hero-image-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
}

.hero-profile-img {
    width: 320px;
    height: 320px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--accent);
    box-shadow: 0 0 0 8px var(--accent-soft), var(--shadow-lg);
    transition: transform var(--transition-slow), box-shadow var(--transition-slow);
}

.hero-profile-img:hover {
    transform: scale(1.03);
    box-shadow: 0 0 0 12px var(--accent-soft), var(--shadow-lg);
}

.hero-text-content {
    flex: 1.4;
}

.badge {
    background-color: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
    color: var(--accent);
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-block;
    margin-bottom: 22px;
    letter-spacing: 0.3px;
}

.hero-text-content h1 {
    font-size: clamp(2rem, 4.5vw, 3.25rem);
    font-weight: 800;
    margin-bottom: 18px;
    line-height: 1.15;
    font-family: var(--font-base);
}

#dynamic-greeting {
    color: var(--accent);
}

.hero-subtitle {
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    color: var(--accent);
    margin-bottom: 22px;
    font-weight: 600;
}

.hero-desc {
    color: var(--text-secondary);
    font-size: 1.08rem;
    margin-bottom: 38px;
    max-width: 600px;
}

.hero-cta-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 28px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: background-color var(--transition), color var(--transition),
                transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    cursor: pointer;
    text-align: center;
    border: 1px solid transparent;
    font-family: var(--font-base);
}

.btn-primary {
    background-color: var(--accent);
    color: #0d1117;
    box-shadow: 0 8px 20px -8px var(--accent-glow);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -10px var(--accent-glow);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-elevated);
    border-color: var(--accent);
    color: var(--accent);
}

/* ---------- Section headings ---------- */
.section-title {
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    font-weight: 800;
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    padding-bottom: 16px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 2px;
}

.section-desc {
    text-align: center;
    color: var(--text-secondary);
    max-width: 720px;
    margin: -20px auto 40px;
    font-size: 1.05rem;
}

/* ============================================================= */
/*                            ABOUT                               */
/* ============================================================= */

.about-section {
    padding: 90px 0;
    background-color: var(--bg-section);
    border-bottom: 1px solid var(--border-color);
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 28px;
}

.about-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 32px;
    border-radius: var(--radius-lg);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.about-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.about-card h3 {
    font-size: 1.2rem;
    margin-bottom: 14px;
    color: var(--accent);
    font-weight: 700;
}

.about-card p {
    color: var(--text-secondary);
    font-size: 0.98rem;
}

/* ============================================================= */
/*                            SKILLS                              */
/* ============================================================= */

.skills-section {
    padding: 90px 0;
    border-bottom: 1px solid var(--border-color);
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
}

.skill-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 28px 22px;
    border-radius: var(--radius-lg);
    text-align: center;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.skill-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent);
    box-shadow: 0 12px 28px -12px var(--accent-glow);
}

.skill-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    font-weight: 800;
    font-size: 1.2rem;
    font-family: var(--font-en);
}

.py-icon  { background: rgba(55, 115, 165, 0.18);  color: #5294c9; }
.js-icon  { background: rgba(247, 223, 30, 0.18);  color: #e2c000; }
.cs-icon  { background: rgba(23, 134, 0, 0.18);    color: #4caf3a; }
.a11y-icon{ background: rgba(227, 76, 38, 0.18);   color: #e34c26; }
.git-icon { background: rgba(240, 80, 50, 0.18);   color: #f05032; }

.skill-card h3 {
    font-size: 1.15rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.skill-card p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
}

/* ============================================================= */
/*                          PROJECTS                              */
/* ============================================================= */

.projects-section {
    padding: 90px 0;
    background-color: var(--bg-section);
    border-bottom: 1px solid var(--border-color);
}

.project-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 40px;
}

.filter-chip {
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    transition: color var(--transition), background-color var(--transition),
                border-color var(--transition), transform var(--transition);
}

.filter-chip:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.filter-chip.is-active {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #0d1117;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 28px;
}

.project-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.project-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.project-card[hidden] {
    display: none !important;
}

.project-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.project-lang {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    display: inline-block;
    margin-bottom: 12px;
    font-family: var(--font-en);
    letter-spacing: 0.4px;
}

.py-tag    { background-color: rgba(55, 115, 165, 0.22); color: #5294c9; }
.js-tag    { background-color: rgba(247, 223, 30, 0.22); color: #e2c000; }
.html-tag  { background-color: rgba(227, 76, 38, 0.22);  color: #e34c26; }
.cs-tag    { background-color: rgba(23, 134, 0, 0.22);   color: #4caf3a; }
.linux-tag { background-color: rgba(255, 204, 0, 0.18);  color: #b8a000; }

:root[data-theme="dark"] .py-tag,
html.theme-dark .py-tag { color: #75b7e5; }
:root[data-theme="dark"] .html-tag,
html.theme-dark .html-tag { color: #ff8a70; }
:root[data-theme="dark"] .cs-tag,
html.theme-dark .cs-tag { color: #74d766; }
:root[data-theme="dark"] .linux-tag,
html.theme-dark .linux-tag { color: #e6cb3d; }

:root[data-theme="light"] .py-tag,
html.theme-light .py-tag { color: #1f5f8f; }
:root[data-theme="light"] .js-tag,
html.theme-light .js-tag { color: #5f5200; }
:root[data-theme="light"] .html-tag,
html.theme-light .html-tag { color: #9f2f13; }
:root[data-theme="light"] .cs-tag,
html.theme-light .cs-tag { color: #176c0d; }
:root[data-theme="light"] .linux-tag,
html.theme-light .linux-tag { color: #5d5200; }

.project-header h3 {
    font-size: 1.22rem;
    font-weight: 700;
    color: var(--text-primary);
}

.project-body {
    padding: 22px 24px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    gap: 18px;
}

.project-body p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.project-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: gap var(--transition), color var(--transition);
}

.project-link:hover {
    color: var(--accent-hover);
    gap: 10px;
    text-decoration: underline;
}

/* ============================================================= */
/*                            CONTACT                             */
/* ============================================================= */

.contact-section {
    padding: 90px 0;
    border-bottom: 1px solid var(--border-color);
}

.contact-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 32px;
    align-items: start;
}

.contact-form {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
}

.contact-form h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 22px;
}

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

.form-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
}

.form-row label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-row input,
.form-row textarea {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--text-primary);
    font: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

.form-row input:focus,
.form-row textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}

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

.form-row.has-error input,
.form-row.has-error textarea {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.18);
}

.form-error {
    display: block;
    color: var(--danger);
    font-size: 0.82rem;
    margin-top: 6px;
    min-height: 1em;
}

.form-status {
    margin-top: 14px;
    font-size: 0.92rem;
    min-height: 1.4em;
}

.form-status.is-success { color: var(--success); }
.form-status.is-error   { color: var(--danger); }

/* Contact aside */
.contact-aside {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
}

.contact-aside h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 22px;
}

.contact-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

.contact-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.contact-link-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.email-reveal-btn {
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    position: relative;
    width: 100%;
    text-align: left;
}

.email-reveal-btn.revealed {
    color: var(--accent);
    border-color: var(--accent);
}

.email-copied-toast {
    display: none;
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    padding: 4px 12px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

/* ============================================================= */
/*                             FOOTER                             */
/* ============================================================= */

.main-footer {
    background-color: var(--bg-main);
    border-top: 1px solid var(--border-color);
    padding: 36px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.a11y-badge {
    color: var(--accent);
    font-size: 0.82rem;
    opacity: 0.9;
}

/* ============================================================= */
/*                         BACK TO TOP                            */
/* ============================================================= */

.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background-color: var(--accent);
    color: #0d1117;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--transition), transform var(--transition), background-color var(--transition);
    z-index: 999;
    border: none;
}

.back-to-top svg {
    width: 22px;
    height: 22px;
}

.back-to-top.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: var(--accent-hover);
}

[dir="rtl"] .back-to-top {
    right: auto;
    left: 24px;
}

/* ============================================================= */
/*                      REVEAL ANIMATIONS                         */
/* ============================================================= */

.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms cubic-bezier(0.4, 0, 0.2, 1),
                transform 600ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
}

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

/* ============================================================= */
/*                        RTL ADJUSTMENTS                         */
/* ============================================================= */

[dir="rtl"] body {
    font-family: var(--font-ar);
}

[dir="rtl"] .hero-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .main-nav ul {
    flex-direction: row-reverse;
}

[dir="rtl"] .project-link {
    flex-direction: row-reverse;
}

[dir="rtl"] .contact-link {
    flex-direction: row-reverse;
}

[dir="rtl"] .hero-desc {
    margin-left: auto;
    margin-right: 0;
}

/* ============================================================= */
/*                         RESPONSIVE                             */
/* ============================================================= */

@media (max-width: 992px) {
    .hero-container,
    [dir="rtl"] .hero-container {
        flex-direction: column;
        text-align: center;
        gap: 40px;
    }

    .hero-text-content {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hero-desc {
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .hero-cta-group {
        justify-content: center;
    }

    .contact-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    html { font-size: 15px; }

    .header-container { height: 64px; }

    .menu-toggle { display: inline-flex; }

    .main-nav {
        position: fixed;
        top: 64px;
        right: 0;
        bottom: 0;
        width: min(82vw, 320px);
        background-color: var(--bg-section);
        border-left: 1px solid var(--border-color);
        padding: 24px;
        transform: translateX(100%);
        transition: transform var(--transition-slow);
        box-shadow: var(--shadow-lg);
        overflow-y: auto;
        visibility: hidden;
        pointer-events: none;
    }

    [dir="rtl"] .main-nav {
        right: auto;
        left: 0;
        border-left: none;
        border-right: 1px solid var(--border-color);
        transform: translateX(-100%);
    }

    .main-nav.is-open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .main-nav ul,
    [dir="rtl"] .main-nav ul {
        flex-direction: column;
        gap: 4px;
    }

    .main-nav a {
        display: block;
        padding: 14px 16px;
        font-size: 1.05rem;
        border-radius: var(--radius-md);
    }

    body.nav-open {
        overflow: hidden;
    }

    body.nav-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        backdrop-filter: blur(4px);
    }

    .hero-section { padding: 60px 0 70px; }
    .about-section,
    .skills-section,
    .projects-section,
    .contact-section { padding: 70px 0; }

    .hero-profile-img {
        width: 240px;
        height: 240px;
    }

    .contact-form,
    .contact-aside { padding: 24px; }
}

@media (max-width: 480px) {
    .hero-cta-group .btn { width: 100%; }
    .theme-toggle-btn { padding: 0 10px; }
}

/* ============================================================= */
/*                    FORCED COLORS / HIGH CONTRAST               */
/* ============================================================= */

@media (forced-colors: active) {
    .forced-colors-notice {
        display: block;
        background: Canvas;
        color: CanvasText;
        border-bottom: 1px solid CanvasText;
    }

    html,
    body,
    .main-header,
    .about-section,
    .projects-section,
    .skills-section,
    .contact-section,
    .main-footer,
    .about-card,
    .skill-card,
    .project-card,
    .contact-form,
    .contact-aside {
        background-color: Canvas !important;
        color: CanvasText !important;
        border-color: CanvasText !important;
    }

    .btn-primary,
    .filter-chip.is-active,
    .back-to-top {
        background-color: Highlight !important;
        color: HighlightText !important;
        border-color: Highlight !important;
    }

    a,
    .project-link,
    .logo a:hover,
    .main-nav a[aria-current="true"] {
        color: LinkText !important;
    }

    *:focus-visible {
        outline-color: Highlight !important;
    }
}

/* ============================================================= */
/*                     REDUCED MOTION SAFETY                      */
/* ============================================================= */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }

    .reveal {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ============================================================= */
/*                          PRINT STYLES                          */
/* ============================================================= */

@media print {
    .main-header,
    .header-actions,
    .menu-toggle,
    .back-to-top,
    .hero-glow,
    .project-filter,
    .contact-form,
    .skip-link {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    a {
        color: #000000 !important;
        text-decoration: underline;
    }

    .project-card,
    .about-card,
    .skill-card {
        break-inside: avoid;
        border: 1px solid #888 !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    .section-title,
    h1, h2, h3 {
        color: #000000 !important;
    }
}
