/* ------------------------------------------------------------------ tokens */
:root {
    --ink: #1d2433;
    --ink-soft: #566176;
    --desk: #e8ecf1;
    --paper: #ffffff;
    --line: #cbd3dd;
    --action: #2a5bd7;
    --action-ink: #ffffff;
    --warn: #a4561a;
    --ok: #2f7a4b;
    --radius-sm: 4px;
    --radius-md: 8px;
    --font: "IBM Plex Sans", "IBM Plex Sans Arabic", "Segoe UI", system-ui, sans-serif;
}

html, body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--desk);
}

body { font-size: 15px; line-height: 1.5; }

h1:focus { outline: none; }

a { color: var(--action); }

.btn-primary {
    --bs-btn-bg: var(--action);
    --bs-btn-border-color: var(--action);
    --bs-btn-hover-bg: #1f4bb8;
    --bs-btn-hover-border-color: #1f4bb8;
}

:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* ------------------------------------------------------------------ chrome */
.topbar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.6rem 1.25rem;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ink);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-mark {
    width: 18px;
    height: 24px;
    border: 2px solid var(--ink);
    border-radius: 2px;
    position: relative;
}
.brand-mark::before {
    content: "";
    position: absolute;
    inset: 3px 3px auto 3px;
    height: 2px;
    background: var(--ink);
    box-shadow: 0 5px 0 var(--ink), 0 10px 0 var(--ink-soft);
}

.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { color: var(--ink-soft); text-decoration: none; }
.topbar nav a.active, .topbar nav a:hover { color: var(--ink); }
.topbar .spacer { flex: 1; }

.lang-switch { display: flex; gap: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px; }
.lang-switch form { margin: 0; }
.lang-switch button { border: none; background: none; padding: 0 0.5rem; border-radius: 3px; color: var(--ink-soft); font-size: 0.85rem; line-height: 1.7; }
.lang-switch button.current { background: var(--ink); color: var(--paper); }

.link-button { background: none; border: none; padding: 0; color: var(--ink-soft); cursor: pointer; }
.link-button:hover { color: var(--ink); }

.page-body { padding: 1.5rem 1.25rem 3rem; max-width: 1500px; margin: 0 auto; }
.narrow { max-width: 960px; margin: 0 auto; }

/* ------------------------------------------------------------------ home */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 3rem; align-items: center; padding: 2rem 0 3rem; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.08; font-weight: 700; letter-spacing: -0.02em; max-width: 14ch; }
.hero p { color: var(--ink-soft); font-size: 1.1rem; max-width: 46ch; }

/* five miniature sheets, each drawn in its market's layout */
.sheet-row { display: flex; gap: 0.9rem; align-items: flex-end; justify-content: center; }
.mini { width: 104px; text-align: center; color: var(--ink); text-decoration: none; }
.mini-paper {
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: 0 1px 0 var(--line), 0 6px 14px rgba(29, 36, 51, 0.08);
    aspect-ratio: 210 / 297;
    display: flex;
    overflow: hidden;
    transition: transform 0.15s ease;
}
.mini.letter .mini-paper { aspect-ratio: 216 / 279; }
.mini:hover .mini-paper { transform: translateY(-4px); }
.mini-side { width: 34%; background: var(--tint); padding: 8px 5px; display: flex; flex-direction: column; gap: 4px; }
.mini-main { flex: 1; padding: 9px 7px; display: flex; flex-direction: column; gap: 4px; }
.mini.centred .mini-main { align-items: center; }
.mini-photo { width: 70%; aspect-ratio: 5 / 6; background: color-mix(in srgb, var(--accent) 35%, white); align-self: center; margin-bottom: 3px; }
.bar { height: 3px; background: #d6dbe2; width: 100%; }
.bar.name { height: 6px; width: 70%; background: var(--accent); }
.bar.rule { height: 1px; background: var(--accent); }
.bar.short { width: 55%; }
.mini-label { margin-top: 0.55rem; font-size: 0.85rem; font-weight: 600; }
.mini-sub { font-size: 0.72rem; color: var(--ink-soft); }

.markets { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.market { background: var(--paper); padding: 1.1rem 1.2rem; border-top: 3px solid var(--accent); }
.market h2 { font-size: 1.05rem; margin: 0 0 0.35rem; }
.market p { color: var(--ink-soft); margin: 0; font-size: 0.92rem; }

/* ------------------------------------------------------------------ list */
.cv-table { width: 100%; background: var(--paper); border: 1px solid var(--line); border-collapse: collapse; }
.cv-table th { text-align: start; font-weight: 500; color: var(--ink-soft); font-size: 0.85rem; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line); }
.cv-table td { padding: 0.75rem 0.9rem; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
.cv-table tr:last-child td { border-bottom: none; }
.region-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; }
.region-chip::before { content: ""; width: 10px; height: 10px; background: var(--accent); border-radius: 2px; }
.row-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }
.empty { background: var(--paper); border: 1px dashed var(--line); padding: 2.5rem; text-align: center; color: var(--ink-soft); }

.new-panel { background: var(--paper); border: 1px solid var(--line); padding: 1.25rem; margin-bottom: 1.25rem; }
.region-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.5rem; }
.region-pick label { border: 1px solid var(--line); padding: 0.6rem 0.75rem; cursor: pointer; border-inline-start: 4px solid var(--accent); }
.region-pick input { margin-inline-end: 0.4rem; }
.region-pick label:has(input:checked) { background: color-mix(in srgb, var(--accent) 8%, white); border-color: var(--accent); }

/* ------------------------------------------------------------------ editor */
.editor-bar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.editor-bar .title-input { font-size: 1.2rem; font-weight: 600; border: 1px solid transparent; background: transparent; padding: 0.2rem 0.4rem; min-width: 12rem; flex: 1; }
.editor-bar .title-input:hover, .editor-bar .title-input:focus { border-color: var(--line); background: var(--paper); }
.editor-bar select { width: auto; }
.save-state { font-size: 0.85rem; color: var(--ink-soft); min-width: 5rem; }
.save-state.saved { color: var(--ok); }

.editor { display: grid; grid-template-columns: minmax(360px, 520px) minmax(0, 1fr); gap: 1.5rem; align-items: start; }

.form-pane { background: var(--paper); border: 1px solid var(--line); }
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: none; padding: 0.65rem 0.85rem; color: var(--ink-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.tab-body { padding: 1rem 1.1rem 1.25rem; }
.tab-body h4 { font-size: 0.98rem; font-weight: 600; margin: 1.25rem 0 0.6rem; }
.tab-body h4:first-child { margin-top: 0; }

.field { margin-bottom: 0.7rem; }
.field label { display: block; font-size: 0.83rem; color: var(--ink-soft); margin-bottom: 0.2rem; }
.field .form-control, .field .form-select { font-size: 0.93rem; }
.field .note { color: var(--warn); }
.field.dim .form-control { color: var(--ink-soft); }
/* each input picks its direction from its content (Latin e-mail inside an Arabic UI, and vice versa) */
.tab-body .form-control { unicode-bidi: plaintext; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }

.item-card { border: 1px solid var(--line); border-inline-start: 3px solid var(--ink-soft); padding: 0.75rem; margin-bottom: 0.75rem; }
.item-tools { display: flex; gap: 0.25rem; justify-content: flex-end; margin-bottom: 0.4rem; }
.item-tools button { font-size: 0.8rem; padding: 0.1rem 0.45rem; }
.add-btn { font-size: 0.9rem; }

.photo-row { display: flex; gap: 1rem; align-items: center; }
.photo-row img { width: 72px; height: 86px; object-fit: cover; border: 1px solid var(--line); }

.preview-pane { position: sticky; top: 64px; }
.desk { background: #d9dfe7; padding: 1.25rem; overflow: auto; max-height: calc(100vh - 220px); border: 1px solid var(--line); }
.checks { background: var(--paper); border: 1px solid var(--line); border-bottom: none; padding: 0.75rem 1rem; }
.checks h3 { font-size: 0.9rem; font-weight: 600; margin: 0 0 0.4rem; display: flex; gap: 0.75rem; align-items: baseline; }
.checks h3 .pages { font-weight: 400; color: var(--ink-soft); }
.checks ul { list-style: none; padding: 0; margin: 0; font-size: 0.86rem; max-height: 7.5rem; overflow: auto; }
.checks li { padding-inline-start: 1rem; position: relative; }
.checks li::before { content: ""; position: absolute; inset-inline-start: 0; top: 0.5em; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); }
.checks li.warn { color: var(--warn); }
.checks li.warn::before { background: var(--warn); }
.checks .ok { color: var(--ok); font-size: 0.86rem; }
.checks details { margin-top: 0.4rem; font-size: 0.85rem; color: var(--ink-soft); }
.checks details ul { margin-top: 0.3rem; }

@media (max-width: 1100px) {
    .editor { grid-template-columns: 1fr; }
    .preview-pane { position: static; }
    .hero { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------- CV sheet (HTML twin of the PDF) */
.sheet {
    --sheet-ink: #222;
    --sheet-muted: #5f6368;
    width: 794px;               /* A4 at 96 dpi */
    min-height: 1123px;
    margin: 0 auto;
    background: #fff;
    color: var(--sheet-ink);
    font-family: "Noto Sans", "Noto Sans Arabic", Arial, sans-serif;
    font-size: 12.7px;
    line-height: 1.3;
    box-shadow: 0 2px 10px rgba(29, 36, 51, 0.14);
    zoom: 0.78;
    display: flex;
}
.sheet.letter { width: 816px; min-height: 1056px; }
.sheet .main { flex: 1; padding: 43px 59px; }
.sheet.sidebar-layout .main { padding: 43px 35px; }
.sheet .side { width: 247px; background: var(--tint); padding: 43px 24px; flex-shrink: 0; }
.sheet h1 { font-size: 30px; font-weight: 700; color: var(--accent); margin: 0; }
.sheet.sidebar-layout h1 { font-size: 32px; }
.sheet .headline { font-size: 15px; color: var(--sheet-muted); margin: 2px 0 0; }
.sheet header { border-bottom: 1.6px solid var(--accent); padding-bottom: 8px; margin-bottom: 14px; }
.sheet.centred header { text-align: center; }
.sheet .contact-row, .sheet .details-row { margin: 4px 0 0; font-size: 12px; }
.sheet .details-row { color: var(--sheet-muted); }
.sheet .sep { margin: 0 0.6em; color: var(--sheet-muted); }
.sheet .photo { display: block; width: 147px; height: 173px; object-fit: cover; border-radius: 8px; margin: 0 auto 18px; }
.sheet .contact-line { font-size: 11.3px; margin-bottom: 4px; overflow-wrap: anywhere; }
.sheet .side section { margin-bottom: 18px; }
.sheet h3 {
    font-size: 14.5px; font-weight: 700; color: var(--accent); letter-spacing: 0.04em;
    text-transform: uppercase; border-bottom: 1px solid var(--accent); padding-bottom: 2px; margin: 0 0 7px;
}
.sheet[dir=rtl] h3 { letter-spacing: 0; }
.sheet .side h3, .sheet .compact h3 { font-size: 12.7px; border-bottom-width: 0.8px; }
.sheet .cv-section { margin-bottom: 14px; }
.sheet .cv-section.compact { margin-bottom: 18px; font-size: 12px; }
.sheet .text { text-align: justify; margin: 0; }
.sheet .entry { margin-bottom: 7px; }
.sheet .entry-head { display: flex; justify-content: space-between; gap: 10px; }
.sheet .entry-title { font-weight: 700; }
.sheet .entry-head .entry-title { font-size: 14px; }
.sheet .dates { color: var(--sheet-muted); white-space: nowrap; }
.sheet .meta { font-style: italic; color: var(--sheet-muted); }
.sheet .muted { color: var(--sheet-muted); }
.sheet .small { font-size: 11px; }
.sheet ul { margin: 2px 0 0; padding-inline-start: 18px; }
.sheet .kv { margin-bottom: 5px; }
.sheet .tags { margin-bottom: 4px; }

@media (max-width: 1400px) { .sheet { zoom: 0.68; } }
@media (max-width: 1100px) { .sheet { zoom: 0.8; } }
@media (max-width: 700px) {
    .sheet { zoom: 0.44; }
    .topbar { flex-wrap: wrap; gap: 0.5rem 1rem; }
    .topbar .spacer { display: none; }
    .sheet-row { flex-wrap: wrap; gap: 0.75rem; }
    .mini { width: 84px; }
    .grid-2 { grid-template-columns: 1fr; }
    .cv-table th:nth-child(3), .cv-table td:nth-child(3), .cv-table th:nth-child(4), .cv-table td:nth-child(4) { display: none; }
    .row-actions { flex-wrap: wrap; }
}

/* ------------------------------------------------------------------ template leftovers */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }
#blazor-error-ui { color-scheme: light only; background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); box-sizing: border-box; display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ------------------------------------------------------------------ legal pages + footer */
.legal { background: var(--paper); border: 1px solid var(--line); padding: 1.75rem 2rem; max-width: 760px; line-height: 1.65; }
.legal h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.legal h2 { font-size: 1.1rem; margin: 1.5rem 0 0.4rem; }
.legal .muted-line { color: var(--ink-soft); font-size: 0.88rem; }
.legal ol, .legal ul { padding-inline-start: 1.3rem; }
.site-footer { display: flex; gap: 1.25rem; justify-content: center; padding: 1.25rem; border-top: 1px solid var(--line); font-size: 0.88rem; }
.site-footer a { color: var(--ink-soft); }
@media (max-width: 700px) { .legal { padding: 1.25rem 1rem; } }

/* ------------------------------------------------------------------ phone fixes */
/* Grid items default to min-width:auto, so the A4 preview widened the whole page. */
.editor > * { min-width: 0; }
@media (max-width: 1100px) { .editor { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) {
    .page-body { padding: 1rem 0.75rem 2rem; }
    .desk { padding: 0.5rem; max-height: none; }
    .editor-bar .title-input { min-width: 0; flex-basis: 100%; }
    .tab-body { padding: 0.85rem 0.75rem 1rem; }
}
@media (max-width: 440px) { .sheet { zoom: 0.4; } }
@media (max-width: 380px) { .sheet { zoom: 0.37; } }
