/* QR Code page — standalone styles. This page has no layout file and does not use the
   RyanCV theme CSS, so everything it needs is here. */

:root {
    --bg-1: #eef2ff;
    --bg-2: #f8fafc;
    --blob-1: rgba(99, 102, 241, .45);
    --blob-2: rgba(236, 72, 153, .35);
    --blob-3: rgba(14, 165, 233, .35);

    --card: rgba(255, 255, 255, .72);
    --card-border: rgba(15, 23, 42, .08);
    --card-shadow: 0 30px 60px -20px rgba(15, 23, 42, .25);

    --field: rgba(255, 255, 255, .85);
    --field-border: rgba(15, 23, 42, .12);

    --text: #0f172a;
    --muted: #64748b;
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, .1);
    --ok: #059669;
    --hint: #b45309;
    --hint-bg: rgba(245, 158, 11, .14);

    --radius: 18px;
    --radius-sm: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-1: #070b18;
        --bg-2: #0f172a;
        --blob-1: rgba(99, 102, 241, .35);
        --blob-2: rgba(236, 72, 153, .25);
        --blob-3: rgba(14, 165, 233, .25);

        --card: rgba(148, 163, 184, .08);
        --card-border: rgba(148, 163, 184, .18);
        --card-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7);

        --field: rgba(15, 23, 42, .55);
        --field-border: rgba(148, 163, 184, .22);

        --text: #e2e8f0;
        --muted: #94a3b8;
        --accent: #818cf8;
        --accent-2: #c084fc;
        --danger: #f87171;
        --danger-bg: rgba(248, 113, 113, .12);
        --ok: #34d399;
        --hint: #fbbf24;
        --hint-bg: rgba(251, 191, 36, .14);
    }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    padding: 40px 20px;
    font-family: 'Segoe UI', Tahoma, 'Iranian Sans', system-ui, -apple-system, Arial, sans-serif;
    color: var(--text);
    background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
    -webkit-font-smoothing: antialiased;
}

/* Soft colour blobs behind everything. Decoration only. */
body::before,
body::after {
    content: '';
    position: fixed;
    z-index: 0;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
}

body::before {
    width: 520px;
    height: 520px;
    top: -180px;
    inset-inline-start: -140px;
    background: var(--blob-1);
}

body::after {
    width: 460px;
    height: 460px;
    bottom: -200px;
    inset-inline-end: -120px;
    background: var(--blob-2);
}

.page {
    position: relative;
    z-index: 1;
    max-width: 1040px;
    margin: 0 auto;
}

/* ---------- header ---------- */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
}

.page-title {
    margin: 0 0 8px;
    font-size: 34px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -.5px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.page-subtitle {
    margin: 0;
    max-width: 46ch;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}

.back-link {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--card-border);
    border-radius: 999px;
    background: var(--card);
    color: var(--text);
    font-size: 14px;
    text-decoration: none;
    transition: transform .15s ease, border-color .15s ease;
}

.back-link:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
}

.back-link i {
    font-size: 12px;
}

/* ---------- card ---------- */

.card {
    display: grid;
    /* minmax(0, …) rather than a bare fr: a grid track's automatic minimum is its content, and
       without this a long unbroken link in the textarea would push the card past the screen. */
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    gap: 0;
    border: 1px solid var(--card-border);
    border-radius: calc(var(--radius) + 6px);
    background: var(--card);
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: hidden;
}

.card-side {
    padding: 30px;
}

.card-side + .card-side {
    border-inline-start: 1px solid var(--card-border);
}

/* ---------- form ---------- */

.field + .field {
    margin-top: 22px;
}

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 9px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--muted);
}

.counter {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    /* "36 / 1000" and "14 px" must keep their order in the Persian page too, where the
       surrounding direction would otherwise flip them to "1000 / 36" and "px 14". */
    direction: ltr;
    unicode-bidi: isolate;
}

.counter.is-over {
    color: var(--danger);
}

textarea.input {
    min-height: 130px;
    resize: vertical;
}

.input {
    width: 100%;
    padding: 13px 15px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--field);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    line-height: 1.6;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.input::placeholder {
    color: var(--muted);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .18);
}

/* segmented control for the error-correction level */

.segmented {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--field);
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented label {
    padding: 9px 4px;
    border-radius: 9px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.segmented label:hover {
    color: var(--text);
}

.segmented input:checked + label {
    color: #fff;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 14px -6px var(--accent);
}

.segmented input:focus-visible + label {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* size slider */

.slider {
    width: 100%;
    height: 6px;
    margin: 10px 0 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 8px rgba(15, 23, 42, .3);
    -webkit-appearance: none;
    appearance: none;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: #fff;
}

/* colours */

.colors {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.color-pick {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 7px 12px 7px 7px;
    border: 1px solid var(--field-border);
    border-radius: 999px;
    background: var(--field);
    font-size: 13px;
    color: var(--muted);
}

.color-pick input[type=color] {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    cursor: pointer;
}

.color-pick input[type=color]::-webkit-color-swatch-wrapper {
    padding: 0;
}

/* A ring, so a very dark or very light swatch is still visible against the field. */
.color-pick input[type=color]::-webkit-color-swatch {
    border: 2px solid rgba(148, 163, 184, .55);
    border-radius: 50%;
}

.color-pick input[type=color]:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.checkbox input {
    width: 17px;
    height: 17px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 13px 22px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-primary {
    width: 100%;
    margin-top: 26px;
    color: #fff;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 14px 26px -14px var(--accent);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px -14px var(--accent);
}

.btn-primary:not(:disabled):active {
    transform: translateY(0);
}

.btn-ghost {
    flex: 1 1 150px;
    border-color: var(--field-border);
    background: var(--field);
    color: var(--text);
}

.btn-ghost:not(:disabled):hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* ---------- preview ---------- */

.preview-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1;
    padding: 16px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius);
    background-color: #fff;
}

/* Checkerboard only while the background really is transparent, so it never adds noise
   behind an ordinary white QR Code. */
.preview.is-transparent {
    background-image: linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
                      linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
                      linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.preview img {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.preview.has-image img {
    display: block;
}

.preview-empty {
    padding: 0 18px;
    color: #94a3b8;
    font-size: 14px;
    line-height: 1.6;
}

.preview-empty i {
    display: block;
    margin-bottom: 10px;
    font-size: 42px;
    opacity: .5;
}

.preview.has-image .preview-empty {
    display: none;
}

.preview.is-loading::after {
    content: '';
    position: absolute;
    width: 34px;
    height: 34px;
    border: 3px solid rgba(99, 102, 241, .25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    max-width: 300px;
    margin-top: 18px;
}

.alert {
    display: none;
    width: 100%;
    max-width: 300px;
    margin-top: 16px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 14px;
    line-height: 1.5;
}

.alert.is-shown {
    display: block;
}

.alert.is-ok {
    background: rgba(5, 150, 105, .12);
    color: var(--ok);
}

/* "the picture is out of date, press Generate" — a nudge, not a failure, so it must not wear
   the red of an error. */
.alert.is-hint {
    background: var(--hint-bg);
    color: var(--hint);
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
    body {
        padding: 26px 16px;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .page-title {
        font-size: 27px;
    }

    .back-link {
        align-self: flex-start;
    }

    .card {
        grid-template-columns: 1fr;
    }

    .card-side {
        padding: 24px 20px;
    }

    .card-side + .card-side {
        border-inline-start: none;
        border-top: 1px solid var(--card-border);
    }
}

/* Phone widths: four correction levels in one row get too tight, so let them sit two by two. */
@media (max-width: 430px) {
    .segmented {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* ---------- rtl ---------- */

[dir=rtl] .page-title,
[dir=rtl] .page-subtitle {
    letter-spacing: 0;
}

[dir=rtl] .back-link i {
    transform: scaleX(-1);
}
