/* ==========================================================================
   PRINTSMILE — Конструктор обложек
   Современная верстка страницы /cover/index.php
   Стили самодостаточны: Foundation для этой страницы больше не нужен.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-sunken: #eef2f8;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --primary: #2a4b9b;
    --primary-hover: #233e83;
    --primary-soft: #eef3ff;
    --primary-ring: rgba(42, 75, 155, 0.18);
    --accent: #f07c22;
    --accent-soft: #fef1e6;
    --danger: #d92d20;
    --danger-soft: #fef1f0;
    --success: #12805c;

    --radius-lg: 18px;
    --radius: 12px;
    --radius-sm: 9px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 4px 14px -6px rgba(15, 23, 42, 0.14);
    --shadow-md: 0 18px 40px -24px rgba(15, 23, 42, 0.28);

    --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background:
        radial-gradient(1100px 420px at 50% -180px, #e6ecfb 0%, rgba(230, 236, 251, 0) 70%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3,
p,
dl,
dd,
dt {
    margin: 0;
}

img,
svg {
    display: block;
}

a {
    color: var(--primary);
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 3px solid var(--primary-ring);
    outline-offset: 2px;
}

.container {
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 24px;
}

.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;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    min-width: 0;
}

.brand__logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 10px;
    background: var(--primary-soft);
    padding: 4px;
}

.brand__name {
    display: flex;
    flex-direction: column;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.15;
    white-space: nowrap;
}

.brand__name small {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--muted);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Buttons ---------- */
.btn {
    --btn-bg: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--btn-bg);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease,
        color 0.16s ease, box-shadow 0.16s ease, transform 0.06s ease;
    white-space: nowrap;
    user-select: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.btn--primary {
    --btn-bg: var(--primary);
    color: #fff;
    box-shadow: 0 8px 18px -10px rgba(42, 75, 155, 0.75);
}

.btn--primary:hover {
    background: var(--primary-hover);
}

.btn--primary:disabled {
    background: var(--border-strong);
    color: #fff;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.75;
}

.btn--outline {
    border-color: var(--border-strong);
    color: var(--text-soft);
    background: var(--surface);
}

.btn--outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.btn--ghost {
    color: var(--text-soft);
}

.btn--ghost:hover {
    background: var(--surface-sunken);
    color: var(--primary);
}

.btn--full {
    width: 100%;
}

/* ---------- Page shell ---------- */
.page {
    flex: 1;
    padding-top: 40px;
    padding-bottom: 56px;
}

/* ---------- Hero ---------- */
.hero {
    text-align: center;
    max-width: 680px;
    margin: 0 auto 30px;
    animation: rise 0.45s ease-out both;
}

.hero__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid rgba(42, 75, 155, 0.16);
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hero__title {
    margin-top: 14px;
    font-size: clamp(28px, 4.2vw, 40px);
    font-weight: 700;
    letter-spacing: -0.028em;
    line-height: 1.12;
}

.hero__lead {
    margin: 12px auto 0;
    max-width: 600px;
    color: var(--muted);
    font-size: 15px;
}

/* ---------- Mode switch ---------- */
.mode-switch {
    display: inline-flex;
    gap: 4px;
    margin: 0 auto 26px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    animation: rise-centered 0.45s 0.05s ease-out both;
}

.mode-switch__btn {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 22px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.mode-switch__btn span {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted-light);
    transition: color 0.18s ease;
}

.mode-switch__btn:hover {
    color: var(--text);
    background: var(--surface-sunken);
}

.mode-switch__btn.is-active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 18px -12px rgba(42, 75, 155, 0.9);
}

.mode-switch__btn.is-active span {
    color: rgba(255, 255, 255, 0.72);
}

/* ---------- Mode blocks ---------- */
.kbs-forms,
.hard-cover-forms {
    animation: fade 0.25s ease-out both;
}

.is-hidden {
    display: none !important;
}

/* ---------- Workspace ---------- */
.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
    gap: 22px;
    align-items: start;
}

/* ---------- Panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 22px 24px 0;
}

.panel__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
}

.panel__icon svg {
    width: 18px;
    height: 18px;
}

.panel__head h2 {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.panel__head p {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.panel__body {
    padding: 20px 24px 24px;
}

/* legacy reveal wrapper — now just a form body */
.reveal,
.reveal-form {
    display: block;
    position: static;
    max-width: none;
    margin: 0;
    padding: 20px 24px 24px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

/* ---------- Fields ---------- */
.field {
    min-width: 0;
}

.field + .field,
.field-row + .field,
.field + .field-row {
    margin-top: 16px;
}

.field-row .field {
    margin-top: 0;
}

.field__label,
.field label,
label.field__label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-soft);
}

.field__hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

.field__control,
.field input[type="number"],
.field input[type="text"],
.field input[type="password"],
.field select,
input[type="number"],
input[type="text"],
input[type="password"],
select {
    display: block;
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
    appearance: none;
}

select {
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.field input:hover,
.field select:hover,
input[type="number"]:hover,
select:hover {
    background-color: #fff;
    border-color: #b6c2d4;
}

.field input:focus,
.field select:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

input::placeholder {
    color: var(--muted-light);
    font-weight: 400;
}

/* number + unit */
.input-unit {
    position: relative;
}

.input-unit input {
    padding-right: 44px;
}

.input-unit__suffix {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    pointer-events: none;
}

/* width x height row */
.field-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
    gap: 14px;
}

.field-row__x {
    display: grid;
    place-items: center;
    width: 26px;
    height: 44px;
    color: var(--muted-light);
    font-size: 16px;
    font-weight: 500;
}

.field-row--split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

/* errors */
.label-error {
    display: block;
    margin: 6px 0 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--danger);
}

.label-error:empty {
    display: none;
}

.is-invalid,
.is-invalid-input {
    border-color: var(--danger) !important;
    background: var(--danger-soft) !important;
    box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.1) !important;
}

/* ---------- Result panel ---------- */
.panel--result {
    position: sticky;
    top: 92px;
    background:
        linear-gradient(180deg, rgba(238, 243, 255, 0.7) 0%, rgba(255, 255, 255, 0) 120px),
        var(--surface);
}

.panel--result .panel__head {
    padding-bottom: 4px;
}

.panel--result .panel__icon {
    background: var(--accent-soft);
    color: var(--accent);
}

.summary {
    padding: 4px 24px 0;
}

.summary__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px dashed var(--border);
}

.summary__row:last-child {
    border-bottom: 0;
}

.summary__row dt {
    font-size: 13px;
    color: var(--muted);
}

.summary__row dd {
    font-size: 14.5px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    text-align: right;
    color: var(--text);
}

.summary__row dd:empty::before,
.summary__row dd.is-empty {
    content: "—";
    color: var(--muted-light);
    font-weight: 500;
}

.result-note {
    display: flex;
    gap: 10px;
    margin: 18px 24px 24px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--muted);
}

.result-note svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--primary);
}

/* ---------- Preview ---------- */
.pdf-block {
    margin-top: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.preview__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.preview__head h2 {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.preview__meta {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.preview__body {
    position: relative;
    padding: 20px 24px 24px;
    background: var(--surface-sunken);
}

.preview__frame {
    position: relative;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    overflow: hidden;
    min-height: 520px;
}

.preview__frame iframe {
    display: block;
    width: 100%;
    height: 70vh;
    min-height: 520px;
    border: 0;
    background: #fff;
}

/* empty state until PDF is generated */
.preview__empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 24px;
    text-align: center;
    background:
        repeating-linear-gradient(45deg, #f8fafc 0 12px, #f2f5fa 12px 24px);
}

.preview__empty-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--muted);
}

.preview__empty-icon svg {
    width: 24px;
    height: 24px;
}

.preview__empty-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-soft);
}

.preview__empty-text {
    max-width: 320px;
    font-size: 12.5px;
    color: var(--muted);
}

.pdf-block.is-ready .preview__empty {
    display: none;
}

.pdf-block:not(.is-ready) .preview__frame {
    min-height: 300px;
}

.pdf-block:not(.is-ready) .preview__frame iframe {
    display: none;
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.6);
}

.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 20px;
    padding-bottom: 20px;
    font-size: 12.5px;
    color: var(--muted);
}

.site-footer a {
    color: var(--text-soft);
    font-weight: 500;
}

.site-footer a:hover {
    color: var(--primary);
}

/* ---------- Login modal (legacy flow, new look) ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal[hidden] {
    display: none;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    animation: fade 0.2s ease-out both;
}

.modal__card {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 28px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    animation: rise 0.25s ease-out both;
}

.modal__card h2 {
    font-size: 19px;
    letter-spacing: -0.015em;
}

.modal__card > p {
    margin: 6px 0 20px;
    font-size: 13px;
    color: var(--muted);
}

.modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.modal__close:hover {
    background: var(--surface-sunken);
    color: var(--text);
}

.modal__close svg {
    width: 18px;
    height: 18px;
}

.modal__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 22px;
}

/* ---------- Animations ---------- */
@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* mode-switch uses translateX(-50%) for centering */
@keyframes rise-centered {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

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

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .panel--result {
        position: static;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }

    .page {
        padding-top: 26px;
        padding-bottom: 40px;
    }

    .site-header__inner {
        min-height: 62px;
    }

    .brand__name small {
        display: none;
    }

    .site-nav .btn--ghost {
        display: none;
    }

    .site-nav .btn {
        height: 38px;
        padding: 0 12px;
        font-size: 13px;
    }

    .hero {
        margin-bottom: 22px;
    }

    .hero__lead {
        font-size: 14px;
    }

    .mode-switch {
        display: flex;
        width: 100%;
        max-width: 420px;
    }

    .mode-switch__btn {
        flex: 1;
        justify-content: center;
        padding: 10px 14px;
        font-size: 14px;
    }

    .mode-switch__btn span {
        display: none;
    }

    .panel__head {
        padding: 18px 18px 0;
    }

    .reveal,
    .reveal-form {
        padding: 16px 18px 20px;
    }

    .panel__body {
        padding: 16px 18px 20px;
    }

    .summary {
        padding: 4px 18px 0;
    }

    .result-note {
        margin: 16px 18px 20px;
    }

    .preview__head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px 18px;
    }

    .preview__head .btn {
        width: 100%;
    }

    .preview__body {
        padding: 14px;
    }

    .preview__frame,
    .preview__frame iframe {
        min-height: 420px;
        height: 58vh;
    }

    .field-row {
        gap: 10px;
    }

    .field-row--split {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .site-footer__inner {
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 400px) {
    .field-row:not(.field-row--split) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .field-row__x {
        display: none;
    }
}
