/* RegaloQR — shared styles for the landing, editor, viewer and print pages. */

:root {
    --accent: #d94f70;
    --accent-ink: #ffffff;
    --bg: #fbf7f2;
    --surface: #ffffff;
    --surface-alt: #f4ede5;
    --text: #2b2521;
    --muted: #7a6f68;
    --line: #e9e0d8;
    --danger: #b3261e;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 10px 30px rgba(43, 37, 33, 0.08);
    --font-display: 'Fraunces', Georgia, serif;
    --font-body:
        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color-scheme: light;
}

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

/* The hidden attribute must win over display rules such as .field { display: flex }. */
[hidden] {
    display: none !important;
}

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

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.15;
    margin: 0 0 0.5em;
    letter-spacing: -0.01em;
}

h1 {
    font-size: clamp(2rem, 6vw, 3.25rem);
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
}

h3 {
    font-size: 1.15rem;
}

p {
    margin: 0 0 1em;
}

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

img {
    max-width: 100%;
    display: block;
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.container {
    width: min(100% - 32px, 44rem);
    margin-inline: auto;
}

.container-wide {
    width: min(100% - 32px, 64rem);
    margin-inline: auto;
}

/* Buttons */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0.65rem 1.4rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background-color 0.15s ease;
}

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

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-primary {
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}

.button-secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
}

.button-ghost {
    background: transparent;
    color: var(--accent);
    padding-inline: 0.75rem;
}

.button-small {
    min-height: 36px;
    padding: 0.35rem 0.9rem;
    font-size: 0.9rem;
}

.button-danger {
    color: var(--danger);
}

/* Top bar */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 0;
}

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

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent);
    display: grid;
    place-items: center;
    color: var(--accent-ink);
    font-size: 0.95rem;
}

/* Landing */

.hero {
    padding: clamp(2.5rem, 8vw, 5rem) 0 clamp(2rem, 6vw, 4rem);
    text-align: center;
}

.hero p.lead {
    font-size: clamp(1.05rem, 2.5vw, 1.3rem);
    color: var(--muted);
    max-width: 36rem;
    margin-inline: auto;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.eyebrow {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.steps {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    counter-reset: step;
    padding: 0;
    margin: 1.5rem 0 0;
    list-style: none;
}

.steps li {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    counter-increment: step;
}

.steps li::before {
    content: counter(step);
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.features {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    padding: 0;
    margin: 1.5rem 0 0;
    list-style: none;
}

.features li {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem;
}

.features .icon {
    font-size: 1.4rem;
    line-height: 1;
}

.landing-section {
    padding: clamp(2rem, 6vw, 4rem) 0;
}

.landing-section + .landing-section {
    border-top: 1px solid var(--line);
}

.footer {
    padding: 2rem 0 3rem;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

/* Forms (editor) */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(1rem, 3vw, 1.5rem);
    box-shadow: var(--shadow);
}

.card + .card {
    margin-top: 1.25rem;
}

.card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.card-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.card-header .hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.hint {
    color: var(--muted);
    font-size: 0.9rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.field label,
.field .label {
    font-weight: 600;
    font-size: 0.95rem;
}

.field-row {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.input,
textarea.input {
    width: 100%;
    min-height: 46px;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s ease;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

textarea.input {
    min-height: 9rem;
    resize: vertical;
    line-height: 1.5;
}

.input[readonly] {
    background: var(--surface-alt);
    color: var(--muted);
}

.input-color {
    width: 56px;
    min-height: 46px;
    padding: 0.2rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

.color-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--line);
    cursor: pointer;
    padding: 0;
}

.swatch[aria-pressed='true'] {
    box-shadow: 0 0 0 2px var(--text);
}

.status {
    font-size: 0.9rem;
    color: var(--muted);
    min-height: 1.3em;
}

.status-ok {
    color: #1f7a4d;
}

.status-error {
    color: var(--danger);
}

.notice {
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
    font-size: 0.95rem;
}

.notice p:last-child {
    margin-bottom: 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

/* Photo picker */

.photo-grid:empty {
    display: none;
}

.photo-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    margin: 1rem 0;
}

.photo-item {
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.photo-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.photo-item .input {
    min-height: 38px;
    border-radius: 0;
    border-inline: none;
    font-size: 0.9rem;
}

.photo-item-tools {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem;
}

.icon-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.3rem 0.45rem;
    border-radius: 6px;
    color: var(--muted);
}

.icon-button:hover {
    background: var(--surface);
    color: var(--text);
}

.icon-button:disabled {
    opacity: 0.35;
    cursor: default;
}

.dropzone {
    display: block;
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.dropzone:hover,
.dropzone.is-over {
    border-color: var(--accent);
    color: var(--text);
}

/* Repeaters (timeline / questions) */

.repeater {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.repeater-item {
    display: grid;
    gap: 0.6rem;
    padding: 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
}

.repeater-item .field {
    margin: 0;
}

.repeater-item-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.repeater-move {
    display: flex;
    gap: 0.25rem;
    margin-right: auto;
}

/* Voice recorder */

.recorder {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.recorder audio {
    width: 100%;
}

.recording-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    50% {
        opacity: 0.3;
    }
}

/* Occasion switch */

.occasion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.6rem;
}

.occasion-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.occasion-card[aria-pressed='true'] {
    border-color: var(--text);
}

.occasion-icon {
    font-size: 1.4rem;
    line-height: 1;
}

textarea.input.input-short {
    min-height: 5rem;
}

/* Theme picker */

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
    gap: 0.6rem;
}

.theme-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.theme-card[aria-pressed='true'] {
    border-color: var(--text);
}

.theme-preview {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--accent);
    font-size: 1.5rem;
    background: linear-gradient(160deg, #120b14, #1c1020);
}

.theme-preview-cielo {
    background: linear-gradient(160deg, #0b1026, #161f45);
}

.theme-preview-atardecer {
    background: linear-gradient(160deg, #26101a, #4a1d1a);
}

.theme-preview-dia {
    background: linear-gradient(160deg, #fbf7f2, #f3e9e1);
}

.theme-preview-fiesta {
    background: linear-gradient(160deg, #1b1033, #2d1b4e);
}

.theme-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.photo-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.photo-item {
    position: relative;
}

.timeline-photo-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.timeline-thumb {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
}

/* Quiz editor */

.quiz-editor-options {
    display: grid;
    gap: 0.5rem;
}

.quiz-editor-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.quiz-editor-option input[type='radio'] {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--accent);
}

/* Video section */

.recorder video {
    width: 100%;
    max-width: 24rem;
    border-radius: 10px;
    background: #000;
}

/* Postcard preview */

.postal-preview {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    margin-bottom: 0.75rem;
}

.postal-preview img {
    width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* Publish section */

.qr-preview {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

@media (min-width: 640px) {
    .qr-preview {
        grid-template-columns: 220px minmax(0, 1fr);
    }
}

.qr-box {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    display: grid;
    place-items: center;
}

.qr-box svg {
    width: 100%;
    height: auto;
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    background: var(--surface-alt);
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    white-space: pre;
}

.sticky-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-top: 1.5rem;
    padding: 0.75rem 0 max(0.75rem, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
}

.sticky-bar .actions {
    justify-content: flex-end;
}

/* Preview overlay */

.preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.preview-overlay[hidden] {
    display: none;
}

.preview-close {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    z-index: 51;
}

/* Print page (screen chrome) */

.print-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.print-toolbar .segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    background: var(--surface-alt);
    padding: 0.25rem;
    border-radius: 999px;
}

.segmented button {
    border: 0;
    background: transparent;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
}

.segmented button[aria-pressed='true'] {
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    font-weight: 600;
}

.print-stage {
    padding: 2rem 16px;
    display: grid;
    place-items: center;
    background: #e8e2db;
    min-height: calc(100vh - 60px);
}

@media print {
    .print-toolbar,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .print-stage {
        padding: 0;
        background: none;
        min-height: 0;
        display: block;
    }
}
