/*
 * وصلة الشاملة — the Jadwal system.
 *
 * Named for the ruled frame that borders a manuscript page. That frame is the
 * one loud element here; everything else is hairlines and restraint.
 *
 * Written entirely in LOGICAL properties (inline-start, margin-inline, padding-
 * block) rather than left/right. One stylesheet serves both an RTL Arabic page
 * and an LTR English one, and there is no second file that can drift from this
 * one. `dir` on <html> is the only switch.
 */

/* ------------------------------------------------------------------ fonts */
/*
 * Self-hosted, split by unicode-range the way Google Fonts serves them: an
 * Arabic reader never downloads the Latin cut and vice versa. Amiri carries
 * the display voice — its shapes descend from the Bulaq press type that
 * classical Arabic books are actually printed in — and Plex Arabic carries
 * body and UI for both scripts, so the two languages sit on one type system.
 */

@font-face {
    font-family: "Amiri";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/assets/amiri-400-arabic.4c2750cf.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
        U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF,
        U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: "Amiri";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/assets/amiri-400-latin.06649aaf.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Plex Arabic";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/assets/plex-400-arabic.4ed189e8.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
        U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF,
        U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: "Plex Arabic";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/assets/plex-400-latin.4a917a99.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Plex Arabic";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/assets/plex-600-arabic.0ccee444.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
        U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF,
        U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: "Plex Arabic";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/assets/plex-600-latin.08b10822.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

/* ------------------------------------------------------------------ tokens */
/*
 * Rubric red is rationed. In a manuscript, red ink means "this is a heading"
 * or "this is a correction" — it is a semantic, not a decoration. It means the
 * same here: markers, errors, and the active nav item. If it starts turning up
 * on ordinary buttons, the system has stopped saying anything.
 */

:root {
    color-scheme: light dark;

    --paper: #f6f6f4;
    --paper-sunk: #eeeeea;
    --ink: #14171c;
    --lapis: #1f3a6e;
    --lapis-hover: #16294e;
    --rubric: #a33a22;
    --rule: #d9d8d2;
    --rule-strong: #c2c1b9;
    --muted: #6a6e78;
    --shadow: rgb(20 23 28 / 6%);

    --font-display: "Amiri", "Amiri Quran", Georgia, "Times New Roman", serif;
    --font-body: "Plex Arabic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --shell: 64rem;
    --prose: 40rem;
    --gap: clamp(2rem, 5vw, 3.25rem);
    --radius: 4px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #12151a;
        --paper-sunk: #181c23;
        --ink: #e7e6e1;
        --lapis: #8fb0e8;
        --lapis-hover: #b4cbf2;
        --rubric: #e08163;
        --rule: #2a2f38;
        --rule-strong: #3b414c;
        --muted: #9aa0ac;
        --shadow: rgb(0 0 0 / 30%);
    }
}

/* ------------------------------------------------------------------- reset */

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

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.7;
    font-feature-settings: "kern";
    -webkit-font-smoothing: antialiased;
}

/*
 * Arabic sits lower and needs more air between lines than Latin at the same
 * size; setting it once here beats correcting it per component.
 */
html[lang="ar"] body {
    line-height: 1.9;
}

img,
svg {
    max-width: 100%;
}

a {
    color: var(--lapis);
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;
}

a:hover {
    color: var(--lapis-hover);
}

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

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    inset-block-start: -100%;
    inset-inline-start: 0.75rem;
    z-index: 10;
    padding: 0.5rem 0.9rem;
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
}

.skip-link:focus {
    inset-block-start: 0.75rem;
}

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

.shell {
    max-inline-size: var(--shell);
    margin-inline: auto;
    padding-inline: clamp(1.15rem, 4vw, 2rem);
}

main {
    display: block;
}

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

.site-header {
    border-block-end: 1px solid var(--rule);
    background: var(--paper);
}

.site-header .shell {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-block-size: 4rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.0625rem;
    margin-inline-end: auto;
}

.brand:hover {
    color: var(--ink);
}

.brand svg {
    inline-size: 1.9rem;
    block-size: 1.9rem;
    color: var(--lapis);
    flex: none;
}

/* The wordmark is set in the display face — the one place the brand speaks. */
.brand-name {
    font-family: var(--font-display);
    font-size: 1.3rem;
    line-height: 1;
    font-weight: 400;
    letter-spacing: 0.01em;
}

html[lang="ar"] .brand-name {
    font-size: 1.45rem;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: clamp(0.75rem, 2.5vw, 1.4rem);
    font-size: 0.9375rem;
}

.site-nav a {
    color: var(--ink);
    text-decoration: none;
}

.site-nav a:hover {
    color: var(--lapis);
    text-decoration: underline;
}

/*
 * The active page is marked with a rubric rule under it, not a colour change
 * on the word — the same job the red marginal stroke does in a manuscript.
 */
.site-nav a[aria-current="page"] {
    color: var(--ink);
    box-shadow: inset 0 -2px 0 0 var(--rubric);
}

.header-divider {
    inline-size: 1px;
    block-size: 1.35rem;
    background: var(--rule-strong);
    flex: none;
}

.lang-toggle {
    font-family: var(--font-body);
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    padding: 0.2rem 0.55rem;
}

.lang-toggle:hover {
    color: var(--ink);
    border-color: var(--ink);
}

.session {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.9375rem;
}

.session-name {
    color: var(--muted);
    max-inline-size: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sign-out is a form post, so it needs a button that reads as a link. */
.linkish {
    font: inherit;
    color: var(--lapis);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.linkish:hover {
    color: var(--lapis-hover);
}

.inline-form {
    display: inline;
    margin: 0;
}

/* ------------------------------------------------------------------- hero */
/*
 * The jadwal. Two rules with a hair of paper between them, exactly as a
 * manuscript page is bordered. Used ONCE, on the hero. Every other division on
 * the site is a single hairline.
 */

.hero {
    padding-block: var(--gap) 0;
}

.jadwal {
    position: relative;
    border: 2px solid var(--rule-strong);
    padding: clamp(2.25rem, 7vw, 4rem) clamp(1.5rem, 6vw, 3.5rem);
    text-align: center;
}

.jadwal::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid var(--rule);
    pointer-events: none;
}

.hero h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2.1rem, 6.5vw, 3.5rem);
    line-height: 1.25;
    margin: 0 0 0.75rem;
    letter-spacing: -0.005em;
}

html[lang="ar"] .hero h1 {
    line-height: 1.45;
}

.hero p {
    margin: 0 auto;
    max-inline-size: 34rem;
    color: var(--muted);
    font-size: 1.0625rem;
}

.hero-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-block-start: 2rem;
}

/* --------------------------------------------------------------- ornament */
/*
 * The three dots of ش, reused as the section mark. It is the logo, so the
 * divider says the brand's own name rather than drawing a neutral line.
 */

.ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: var(--rule-strong);
}

.ornament::before,
.ornament::after {
    content: "";
    block-size: 1px;
    flex: 1;
    background: var(--rule);
}

.ornament span {
    display: block;
    inline-size: 4px;
    block-size: 4px;
    border-radius: 50%;
    background: currentColor;
}

/* -------------------------------------------------------------- sections */

.section {
    padding-block: var(--gap);
}

.section > h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    line-height: 1.3;
    margin: 0 0 1.5rem;
}

.lede {
    max-inline-size: var(--prose);
    font-size: 1.0625rem;
    margin: 0;
}

/* -------------------------------------------------------------- stat row */

/*
 * Flush under the hero, sharing its width: the figures read as a caption to
 * the frame rather than as a separate band. No top border — the jadwal's own
 * bottom rule is the line, and adding another put two hairlines 1px apart.
 */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 1px;
    background: var(--rule);
    border-block-end: 1px solid var(--rule);
    list-style: none;
    padding: 0;
    margin: 0;
}

.stats li {
    background: var(--paper);
    padding: 1.25rem 1rem;
    text-align: center;
}

.stats b {
    display: block;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.9rem;
    line-height: 1.2;
    font-variant-numeric: lining-nums;
}

.stats span {
    display: block;
    font-size: 0.875rem;
    color: var(--muted);
}

/* ----------------------------------------------------------------- steps */
/*
 * Numbered, because connecting really is a sequence: the URL is useless before
 * the client is open, and the sign-in cannot happen before the URL is pasted.
 * Numbers that encode nothing would be decoration; these carry the order.
 */

.steps {
    list-style: none;
    counter-reset: step;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 1.75rem;
    max-inline-size: var(--prose);
}

.steps > li {
    counter-increment: step;
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 1rem;
    align-items: start;
}

.steps > li::before {
    content: counter(step);
    font-family: var(--font-display);
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--rubric);
    text-align: center;
    border-block-end: 1px solid var(--rubric);
}

.steps h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 600;
}

.steps p {
    margin: 0;
    color: var(--muted);
}

/* ------------------------------------------------------------------ code */

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    direction: ltr;
    unicode-bidi: isolate;
}

.endpoint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-block-start: 0.75rem;
}

/*
 * `user-select: all` so one click selects the whole address — the copy button
 * is progressive enhancement and this is what a visitor without it does.
 * `overflow-x: auto` because a URL is one unbreakable token: on a narrow
 * screen it scrolls inside its own box rather than widening the page.
 */
.endpoint code {
    display: block;
    max-inline-size: 100%;
    overflow-x: auto;
    background: var(--paper-sunk);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.55rem 0.8rem;
    font-size: 0.9375rem;
    user-select: all;
}

.copy-button {
    font: inherit;
    font-size: 0.875rem;
    color: var(--muted);
    background: none;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    padding: 0.4rem 0.7rem;
    cursor: pointer;
}

.copy-button:hover {
    color: var(--ink);
    border-color: var(--ink);
}

/* -------------------------------------------------------------- examples */
/*
 * Real prompts, quoted as prompts. The marginal rule is the manuscript's way
 * of saying "this is quoted material", and it does the same work here.
 */

.prompts {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 1rem;
    max-inline-size: var(--prose);
}

.prompts li {
    border-inline-start: 2px solid var(--rule-strong);
    padding-inline-start: 1rem;
    color: var(--ink);
}

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

.button {
    display: inline-block;
    font: inherit;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    padding: 0.6rem 1.35rem;
    border-radius: var(--radius);
    border: 1px solid var(--lapis);
    background: var(--lapis);
    color: var(--paper);
    cursor: pointer;
    text-align: center;
}

.button:hover {
    background: var(--lapis-hover);
    border-color: var(--lapis-hover);
    color: var(--paper);
}

.button-quiet {
    background: none;
    color: var(--lapis);
}

.button-quiet:hover {
    background: none;
    color: var(--lapis-hover);
    border-color: var(--lapis-hover);
}

.button-block {
    display: block;
    inline-size: 100%;
}

/* ----------------------------------------------------------------- prose */

.prose {
    max-inline-size: var(--prose);
    padding-block: var(--gap);
}

.prose h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.85rem, 5vw, 2.6rem);
    line-height: 1.3;
    margin: 0 0 0.5rem;
}

.prose > p:first-of-type {
    color: var(--muted);
}

.prose h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.4rem;
    line-height: 1.4;
    margin: 2.5rem 0 0.75rem;
    padding-block-end: 0.4rem;
    border-block-end: 1px solid var(--rule);
}

.prose h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.75rem 0 0.4rem;
}

.prose p,
.prose li {
    margin-block: 0 0.85rem;
}

.prose ul,
.prose ol {
    padding-inline-start: 1.35rem;
}

.prose .updated {
    font-size: 0.875rem;
    color: var(--muted);
    margin-block-end: 2rem;
}

.prose dl {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1.25rem;
}

.prose dt {
    color: var(--muted);
    font-size: 0.9375rem;
}

.prose dd {
    margin: 0;
}

/* ------------------------------------------------------------------ note */

.note {
    border-inline-start: 2px solid var(--rubric);
    background: var(--paper-sunk);
    padding: 0.85rem 1rem;
    margin-block: 1.5rem;
    font-size: 0.9375rem;
}

.note p {
    margin: 0;
}

/* ----------------------------------------------------------------- forms */
/*
 * The auth pages. Still a single narrow column and still no client JavaScript
 * — these are reached from an embedded browser view inside an MCP client, and
 * a sign-in that silently does nothing because a script did not run is the
 * worst failure at the worst moment.
 */

.card {
    max-inline-size: 26rem;
    margin-inline: auto;
    padding-block: clamp(2.5rem, 8vh, 4.5rem);
}

.card h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.85rem;
    line-height: 1.35;
    margin: 0 0 0.35rem;
}

.card > p.sub {
    margin: 0 0 2rem;
    color: var(--muted);
}

.field {
    display: block;
    margin-block-end: 1.15rem;
}

.field > span {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-block-end: 0.35rem;
}

.field .hint {
    display: block;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--muted);
    margin-block-start: 0.3rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    inline-size: 100%;
    font: inherit;
    padding: 0.55rem 0.7rem;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
}

textarea {
    min-block-size: 8rem;
    resize: vertical;
}

input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--lapis);
    outline-offset: 1px;
    border-color: var(--lapis);
}

/* The honeypot. Hidden from people, reachable by a bot that fills everything. */
.trap {
    position: absolute;
    inset-inline-start: -9999px;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
}

.error,
.notice {
    border-radius: var(--radius);
    padding: 0.7rem 0.85rem;
    margin-block-end: 1.5rem;
    font-size: 0.9375rem;
    border-inline-start: 2px solid;
    background: var(--paper-sunk);
}

.error {
    border-color: var(--rubric);
}

.notice {
    border-color: var(--lapis);
}

.error p,
.notice p {
    margin: 0;
}

.error p + p,
.notice p + p {
    margin-block-start: 0.5rem;
}

.form-footer {
    margin-block-start: 1.5rem;
    font-size: 0.9375rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    justify-content: space-between;
}

.scopes {
    list-style: none;
    padding: 0;
    margin: 0 0 1.75rem;
    border-block: 1px solid var(--rule);
}

.scopes li {
    padding: 0.6rem 0;
    font-size: 0.9375rem;
}

.scopes li + li {
    border-block-start: 1px solid var(--rule);
}

.row {
    display: flex;
    gap: 0.75rem;
}

.row > form {
    flex: 1;
    margin: 0;
}

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

.site-footer {
    border-block-start: 1px solid var(--rule);
    margin-block-start: var(--gap);
    padding-block: 2rem 2.5rem;
    font-size: 0.9375rem;
    color: var(--muted);
}

.site-footer .shell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.5rem;
    align-items: baseline;
    justify-content: space-between;
}

.site-footer nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.25rem;
}

.site-footer a {
    color: var(--muted);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--lapis);
    text-decoration: underline;
}

/* ------------------------------------------------------------ small print */

@media (max-width: 34rem) {
    .site-header .shell {
        padding-block: 0.75rem;
    }

    .site-nav {
        inline-size: 100%;
        order: 3;
        gap: 1rem;
        padding-block-start: 0.15rem;
    }

    .header-divider {
        display: none;
    }

    .hero-actions .button {
        inline-size: 100%;
    }
}
