/* =========================================================================
   CanvaTool — base stylesheet
   Pure CSS3. No framework, no build step. Logical properties throughout so
   the Arabic (RTL) build works from the same rules.
   ========================================================================= */

:root {
    --brand: #5b21b6;
    --brand-600: #6d28d9;
    --brand-500: #7c3aed;
    --brand-100: #ede9fe;
    --accent: #ec4899;

    --ink: #14121a;
    --ink-2: #3f3d4a;
    --ink-3: #6b6878;
    --line: #e5e2ec;
    --surface: #ffffff;
    --surface-2: #f7f5fb;
    --surface-3: #efecf6;

    --ok: #047857;
    --warn: #b45309;
    --danger: #be123c;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 22px;

    --shadow-sm: 0 1px 2px rgba(20, 18, 26, .06), 0 1px 3px rgba(20, 18, 26, .08);
    --shadow: 0 4px 6px -1px rgba(20, 18, 26, .07), 0 10px 24px -8px rgba(20, 18, 26, .18);
    --shadow-lg: 0 24px 48px -16px rgba(20, 18, 26, .28);

    --shell: 1200px;
    --header-h: 64px;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-mono: 'Roboto Mono', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f4f2f9;
        --ink-2: #cdc9da;
        --ink-3: #9d99ad;
        --line: #2e2b38;
        --surface: #16141c;
        --surface-2: #1d1b25;
        --surface-3: #262331;
        --brand-100: #2a1d4d;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
        --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
        --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .8);
    }
}

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` attribute is how the JS toggles panels, modals and toasts.
   Any class rule that sets `display` would otherwise beat the UA default,
   so it is pinned here once for every component. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--surface-2);
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }

a { color: var(--brand-500); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-600); }

:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; border-radius: 4px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; inset-inline-start: -9999px; top: 0; z-index: 999;
    background: var(--brand); color: #fff; padding: .75rem 1.25rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { inset-inline-start: 0; }

.shell { width: min(100% - 2.5rem, var(--shell)); margin-inline: auto; }

/* ------------------------------------------------------------------ header */

.site-header {
    position: sticky; top: 0; z-index: 60;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.site-header__inner {
    display: flex; align-items: center; gap: 1rem;
    min-height: var(--header-h);
}

.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand__name { font-size: 1.05rem; letter-spacing: -.02em; }

.nav-toggle {
    margin-inline-start: auto; display: none; width: 42px; height: 42px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); cursor: pointer; position: relative;
}
.nav-toggle__bar, .nav-toggle__bar::before, .nav-toggle__bar::after {
    position: absolute; left: 11px; width: 18px; height: 2px; background: var(--ink); content: '';
    transition: transform .2s ease;
}
.nav-toggle__bar { top: 20px; }
.nav-toggle__bar::before { top: -6px; }
.nav-toggle__bar::after { top: 6px; }

.primary-nav { margin-inline-start: auto; display: flex; align-items: center; gap: 1.5rem; }
.primary-nav__list { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; }
.primary-nav__list a { color: var(--ink-2); text-decoration: none; font-weight: 500; padding: .4rem 0; }
.primary-nav__list a:hover, .primary-nav__list a.is-active { color: var(--brand-500); }
.primary-nav__actions { display: flex; align-items: center; gap: .6rem; }

.lang-switcher, .user-menu { position: relative; }
.lang-switcher > summary, .user-menu > summary {
    list-style: none; cursor: pointer; padding: .45rem .7rem; border: 1px solid var(--line);
    border-radius: 999px; background: var(--surface); font-size: .875rem; display: inline-flex; gap: .4rem; align-items: center;
}
.lang-switcher > summary::-webkit-details-marker, .user-menu > summary::-webkit-details-marker { display: none; }
.lang-switcher__list, .user-menu__list {
    position: absolute; inset-inline-end: 0; top: calc(100% + .4rem); min-width: 190px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); list-style: none; margin: 0; padding: .35rem; z-index: 70;
}
.lang-switcher__list a, .user-menu__list a, .user-menu__list button {
    display: block; width: 100%; text-align: start; padding: .5rem .65rem; border-radius: var(--radius-sm);
    color: var(--ink-2); text-decoration: none; font-size: .9rem;
}
.lang-switcher__list a:hover, .user-menu__list a:hover, .user-menu__list button:hover { background: var(--surface-3); color: var(--ink); }
.lang-switcher__list a.is-active { color: var(--brand-500); font-weight: 600; }
.linklike { border: 0; background: none; font: inherit; cursor: pointer; color: var(--ink-2); }

/* ------------------------------------------------------------------ buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .7rem 1.15rem; border-radius: 999px; border: 1px solid transparent;
    font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: linear-gradient(135deg, var(--brand-600), var(--accent)); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { color: #fff; box-shadow: var(--shadow); }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--brand-500); color: var(--brand-500); }
.btn--sm { padding: .45rem .85rem; font-size: .85rem; }
.btn--block { width: 100%; }
.btn--danger { background: var(--danger); color: #fff; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }

/* ------------------------------------------------------------------- forms */

.field { display: block; margin-bottom: 1rem; }
.field > span, .field > label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=search], select, textarea {
    width: 100%; padding: .65rem .8rem; font: inherit; font-size: .95rem; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-500); outline: none; box-shadow: 0 0 0 3px var(--brand-100); }
textarea { min-height: 140px; resize: vertical; }
.checkbox { display: flex; align-items: flex-start; gap: .55rem; font-size: .9rem; color: var(--ink-2); }
.checkbox input { margin-top: .25rem; }
.hint { font-size: .8rem; color: var(--ink-3); }

/* ------------------------------------------------------------------ layout */

.main { min-height: 60vh; padding-block: 2rem 4rem; }
.section { margin-block: 3rem; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.section__head h2 { margin: 0; }

.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem;
}

.flash { padding: .85rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; font-size: .92rem; }
.flash--success { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.flash--error { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent); }
.flash ul { margin: 0; padding-inline-start: 1.1rem; }

/* -------------------------------------------------------------------- hero */

.hero { padding-block: clamp(2rem, 5vw, 4.5rem); text-align: center; }
.hero__title { margin-bottom: .4em; }
.hero__title em { font-family: var(--font-display); font-style: italic; color: var(--brand-500); }
.hero__sub { font-size: clamp(1rem, .95rem + .4vw, 1.2rem); color: var(--ink-2); max-width: 60ch; margin-inline: auto; }
.hero__cta { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.75rem; }

.preset-strip { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-top: 2rem; }
.preset-chip {
    display: inline-flex; flex-direction: column; align-items: center; gap: .15rem;
    padding: .55rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); text-decoration: none; color: var(--ink-2); font-size: .82rem;
}
.preset-chip:hover { border-color: var(--brand-500); color: var(--brand-500); }
.preset-chip small { color: var(--ink-3); font-size: .72rem; }

/* ------------------------------------------------------------------- grids */

.grid { display: grid; gap: 1.1rem; }
.grid--templates { grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.grid--categories { grid-template-columns: repeat(auto-fill, minmax(min(100%, 165px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }

.template-card {
    display: flex; flex-direction: column; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
    text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s ease;
}
.template-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); color: inherit; }
.template-card__thumb { position: relative; aspect-ratio: 4 / 5; background: var(--surface-3); overflow: hidden; }
.template-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.template-card__body { padding: .7rem .85rem .9rem; }
.template-card__title { font-size: .92rem; font-weight: 600; margin: 0 0 .15rem; }
.template-card__meta { font-size: .78rem; color: var(--ink-3); }

.badge {
    position: absolute; inset-block-start: .55rem; inset-inline-end: .55rem;
    padding: .15rem .5rem; border-radius: 999px; font-size: .7rem; font-weight: 700;
    background: rgba(20, 18, 26, .78); color: #fff; letter-spacing: .02em;
}
.badge--pro { background: linear-gradient(135deg, var(--brand-600), var(--accent)); }

.category-card {
    display: flex; flex-direction: column; gap: .3rem; padding: 1rem;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
    text-decoration: none; color: inherit;
}
.category-card:hover { border-color: var(--brand-500); color: inherit; }
.category-card strong { font-size: .95rem; }
.category-card span { font-size: .78rem; color: var(--ink-3); }

.feature { padding: 1.5rem; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.feature h3 { margin-bottom: .35rem; }
.feature p { margin: 0; color: var(--ink-2); font-size: .95rem; }

/* ------------------------------------------------------------- toolbar/list */

.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
.toolbar form { display: flex; gap: .5rem; flex: 1 1 260px; }
.toolbar select, .toolbar input { max-width: 260px; }

.chips { display: flex; gap: .45rem; flex-wrap: wrap; list-style: none; margin: 0 0 1.5rem; padding: 0; }
.chips a {
    display: inline-block; padding: .35rem .8rem; border-radius: 999px; font-size: .85rem;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); text-decoration: none;
}
.chips a.is-active, .chips a:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.pagination { display: flex; gap: .35rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: .45rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--surface); color: var(--ink-2); text-decoration: none; font-size: .88rem;
}
.pagination .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.pill--ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill--warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pill--danger { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.pill--muted { background: var(--surface-3); color: var(--ink-3); }

/* --------------------------------------------------------------- ad slots */

.ad-slot { display: flex; justify-content: center; margin-block: 1.5rem; min-height: 0; }
.ad-slot--sidebar { margin-block: 1rem; }
.ad-slot:empty { display: none; }

/* ---------------------------------------------------------------- pricing */

.plan-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.plan { display: flex; flex-direction: column; padding: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.plan--featured { border-color: var(--brand-500); box-shadow: var(--shadow); position: relative; }
.plan h3 { font-size: 1.35rem; }
.plan ul { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .5rem; font-size: .92rem; }
.plan li { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--line); padding-bottom: .5rem; }
.plan li span:last-child { color: var(--ink-2); font-weight: 600; text-align: end; }

/* ------------------------------------------------------------------ footer */

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding-block: 2.5rem 1.5rem; margin-top: 3rem; }
.site-footer__grid { display: grid; gap: 2rem; grid-template-columns: 2fr repeat(3, 1fr); }
.site-footer h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.site-footer a { color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.site-footer a:hover { color: var(--brand-500); }
.site-footer__brand p { color: var(--ink-3); font-size: .9rem; max-width: 38ch; }
.site-footer__legal { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--ink-3); }

/* ------------------------------------------------------------------ authpg */

.auth-wrap { max-width: 430px; margin-inline: auto; }
.auth-wrap .card { padding: 1.75rem; }
.auth-wrap h1 { font-size: 1.6rem; }
.auth-alt { text-align: center; margin-top: 1rem; font-size: .9rem; color: var(--ink-3); }

/* --------------------------------------------------------------- dashboard */

.dash-layout { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; align-items: start; }
.dash-nav { position: sticky; top: calc(var(--header-h) + 1rem); }
.dash-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.dash-nav a {
    display: block; padding: .55rem .75rem; border-radius: var(--radius-sm);
    color: var(--ink-2); text-decoration: none; font-size: .92rem;
}
.dash-nav a:hover { background: var(--surface-3); }
.dash-nav a.is-active { background: var(--brand-100); color: var(--brand-600); font-weight: 600; }

.stat-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); margin-bottom: 2rem; }
.stat { padding: 1rem 1.15rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.stat strong { display: block; font-size: 1.65rem; line-height: 1.15; }
.stat span { font-size: .8rem; color: var(--ink-3); }

.design-card { position: relative; }
.design-card__select { position: absolute; inset-block-start: .5rem; inset-inline-start: .5rem; z-index: 2; width: 20px; height: 20px; }
.design-card__actions { display: flex; gap: .35rem; flex-wrap: wrap; padding: 0 .85rem .85rem; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-3); }

/* ---------------------------------------------------------------- article */

.prose { max-width: 72ch; }
.prose h2 { margin-top: 2rem; }
.prose ul { padding-inline-start: 1.25rem; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
    .site-footer__grid { grid-template-columns: 1fr 1fr; }
    .dash-layout { grid-template-columns: 1fr; }
    .dash-nav { position: static; }
    .dash-nav ul { display: flex; flex-wrap: wrap; }
}

@media (max-width: 760px) {
    .nav-toggle { display: block; }
    .primary-nav {
        position: fixed; inset-block-start: var(--header-h); inset-inline: 0;
        background: var(--surface); border-bottom: 1px solid var(--line);
        flex-direction: column; align-items: stretch; gap: 1rem; padding: 1rem 1.25rem 1.5rem;
        display: none; box-shadow: var(--shadow);
    }
    .primary-nav.is-open { display: flex; }
    .primary-nav__list { flex-direction: column; gap: .35rem; }
    .primary-nav__actions { flex-wrap: wrap; }
    .lang-switcher__list, .user-menu__list { position: static; box-shadow: none; }
}

@media (max-width: 560px) {
    .site-footer__grid { grid-template-columns: 1fr; }
    .grid--templates { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
