/**
 * Shared block styles for mobile editor and reflow player
 * This file ensures consistent text rendering between editing and viewing
 *
 * Include this file BEFORE mobile-editor.css and reflow-player.css
 */

/* Base block spacing */
.block {
    margin-bottom: 24px;
    position: relative;
}

/* Kicker — eyebrow label rendered as an outline pill above the title.
 * Shared by the player (div.block-kicker > span.kicker-pill) and the editor
 * (same markup, with a non-editable icon chip + contenteditable .kicker-text).
 * Color is the theme accent token so it adapts across themes. */
.block-kicker {
    margin: 0 0 12px 0; /* --space-3 */
}
.kicker-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px; /* --space-2 */
    padding: 4px 12px; /* --space-1 / --space-3 */
    border: 1px solid var(--theme-accent, #C4B5FD);
    border-radius: 9999px; /* --radius-full (pill) */
    color: var(--theme-accent, #C4B5FD);
    font-family: var(--theme-heading-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: clamp(11px, 3vw, 13px); /* --font-size-xs..sm */
    font-weight: 600;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
    vertical-align: middle;
}
.kicker-pill .kicker-icon,
.kicker-pill .flow-icon {
    display: inline-flex;
    align-items: center;
    width: 1em;
    height: 1em;
}
.kicker-text {
    display: inline-block;
}

/* Editor-only affordances on the kicker pill: tappable icon chip. */
.kicker-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    line-height: 1;
}
.kicker-icon-btn.is-empty {
    opacity: 0.5;
}
.kicker-icon-btn .kicker-icon-add {
    font-size: 1.1em;
    font-weight: 600;
}

/* Title blocks */
.block-title {
    font-family: var(--theme-heading-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-weight: var(--theme-heading-weight, 700);
    font-size: clamp(28px, 8vw, 42px);
    line-height: 1.15;
    letter-spacing: var(--theme-letter-spacing, -0.02em);
    margin: 0 0 20px 0;
    word-break: keep-all;
    white-space: normal;
    hyphens: none;
}

/* Subtitle blocks */
.block-subtitle {
    font-family: var(--theme-heading-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-weight: 500;
    font-size: clamp(18px, 5vw, 28px);
    line-height: 1.25;
    letter-spacing: var(--theme-letter-spacing, 0);
    opacity: 0.85;
    margin: 0 0 20px 0;
    word-break: keep-all;
    white-space: normal;
    hyphens: none;
}

/* Body text blocks */
.block-body {
    font-family: var(--theme-body-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-weight: var(--theme-body-weight, 400);
    font-size: clamp(16px, 4.5vw, 20px);
    line-height: var(--theme-line-height, 1.5);
    margin: 0 0 20px 0;
    word-break: keep-all;
    white-space: normal;
    hyphens: none;
}

/* Quote blocks */
.block-quote {
    font-family: var(--theme-body-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-style: italic;
    font-size: clamp(16px, 4.5vw, 20px);
    line-height: 1.4;
    padding: 16px 20px;
    border-left: 4px solid var(--theme-secondary, currentColor);
    background: rgba(255,255,255,0.08);
    border-radius: 0 12px 12px 0;
    margin: 0 0 20px 0;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

/* Bullet list blocks - base styles.
 * The player renders bullets as inline <span class="bullet-accent"> inside a
 * <div class="block-bullet-list"> (see reflow-player.src.js formatBulletList),
 * not as <li> elements. The editor renders <ul class="block-bullet-list"><li>
 * and owns all li styling in mobile-editor.css L510+. So no li::before rules
 * are needed here — they were dead for the player and collided with the
 * editor's rules (producing double-bullets via CSS cascade). */
.block-bullet-list,
.block-bullets {
    font-family: var(--theme-body-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: clamp(16px, 4.5vw, 20px);
    line-height: var(--theme-line-height, 1.6);
    margin: 0 0 20px 0;
    padding-left: 0;
    list-style: none;
}

/* Image blocks */
.block-image {
    border-radius: var(--theme-image-radius, 12px);
    overflow: hidden;
    background: rgba(0,0,0,0.2);
    margin: 0 auto 24px auto;
    box-shadow: var(--theme-image-shadow, none);
}

/* Cap inline images on desktop/iPad. Two-pronged:
   1) Targets IMG directly inside known wrappers (.block-image,
      .block-resolved-image) — the wrappers themselves sit in a flex
      column with align-items: stretch so capping the wrapper gets
      stretched anyway; capping the img + margin: 0 auto centers it
      inside the (invisibly wide) wrapper.
   2) Broad fallback for any img inside screen-content not covered by
      a more-specific rule, with class exclusions for hero, toc, footer,
      and team avatars (which size themselves via inline width). */
.screen:not(.screen-hero) .block-image > img,
.screen:not(.screen-hero) .block-resolved-image > img {
    max-width: 280px !important;
    width: 100% !important;
    margin: 0 auto !important;
    display: block !important;
}

.screen:not(.screen-hero) .screen-content img:not(.hero-bg-image):not(.toc-thumb):not(.footer-author-avatar):not(.footer-logo):not(.team-avatar):not(.slider-img) {
    max-width: 280px;
    height: auto;
    margin-left: auto;
    margin-right: auto;
}

.block-image img {
    width: 100%;
    display: block;
}

/* Resolved AI-generated images */
.block-resolved-image {
    margin: 24px auto !important;
    width: 100% !important;
    max-width: 280px !important;
    align-self: center !important;
    border-radius: var(--theme-image-radius, 16px);
    overflow: hidden;
    box-shadow: var(--theme-image-shadow, 0 8px 32px rgba(0, 0, 0, 0.15));
}

.block-resolved-image img {
    width: 100%;
    display: block;
}

/* Screen content container - shared base */
.screen-content {
    min-height: 100%;
    padding: var(--theme-padding-y, 40px) var(--theme-padding-x, 24px) 80px var(--theme-padding-x, 24px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    text-align: var(--theme-text-align, center);
    max-width: var(--theme-content-width, 90%);
    margin-left: var(--theme-content-offset, auto);
    margin-right: auto;
    gap: var(--theme-element-gap, 16px);
}

/* First screen gets top padding for header */
.screen:first-child .screen-content {
    padding-top: max(70px, calc(env(safe-area-inset-top) + 16px));
}

/* Title screens - both .screen-title and .screen-type-title for compatibility */
.screen-title .screen-content,
.screen-type-title .screen-content {
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.screen-title .block-title,
.screen-type-title .block-title {
    font-size: clamp(42px, 12vw, 72px) !important;
    line-height: 1.1;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.screen-title .block-subtitle,
.screen-type-title .block-subtitle {
    font-size: clamp(20px, 5vw, 32px) !important;
    line-height: 1.35;
    opacity: 0.8;
    font-weight: 400;
}

/* Images on title screens - full width, centered */
.screen-title .block-image,
.screen-type-title .block-image {
    max-width: 100%;
    width: 100%;
    margin: 0 auto 24px auto;
}

/* Closing screens - always centered regardless of theme */
.screen-type-closing .screen-content {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 60px 32px;
    margin-left: auto;
    margin-right: auto;
}

.screen-type-closing .block-title {
    font-size: clamp(42px, 12vw, 72px) !important;
    line-height: 1.1;
    margin-bottom: 20px;
}

/* Hero screens - text over background */
.screen-hero .screen-content .block-title,
.screen-hero .screen-content .block-subtitle,
.screen-hero .screen-content .block-body {
    color: #fff !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ==========================================
   Theme Decorations
   ========================================== */

/* Decorations container. Decorations need to sit *above* the opaque
   screen-content background (non-hero screens get an inline theme-bg
   color on .screen-content that otherwise covers a translucent flare).
   The elements inside are low-opacity + blurred, so text legibility
   is preserved. */
.screen-decorations {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

/* Content sits under decorations in z order but its bg paints first
   (non-positioned bg). Decorations (positioned absolute) paint on top. */
.screen-content {
    position: relative;
    z-index: 1;
}

/* Under-content decoration layer. Opaque color-block plates (Mondrian) render
   here instead of .screen-decorations: that layer sits at z:2 ABOVE content
   (translucent glows must clear the opaque content bg some themes set), so an
   opaque element there covers text — the "rectangles above content" bug. This
   layer sits above the screen's theme bg but below .screen-content (z:1).
   The editor nests decorations INSIDE .screen-content, so the nested variant
   needs negative z to slip under the in-flow text blocks. */
.screen-decorations-under {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.screen-content > .screen-decorations-under {
    z-index: -1;
}

/* Gradient blob decorations */
.decoration-blob {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

/* Scanline decorations */
.decoration-scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Accent line decorations */
.decoration-accent-line {
    position: absolute;
    pointer-events: none;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .decoration-blob,
    .decoration-scanlines,
    .decoration-accent-line {
        animation: none !important;
        transition: none !important;
    }
}

/* ==========================================
   Team Block
   ========================================== */
.block-team {
    padding: 16px 0;
}

.block-team .team-member {
    transition: transform 0.2s ease;
}

.block-team .team-member:hover {
    transform: translateY(-2px);
}

/* ==========================================
   Comparison Table Block
   ========================================== */
.block-comparison-table {
    margin: 16px 0;
    border-radius: 12px;
    overflow: hidden;
}

.block-comparison-table table {
    border-collapse: collapse;
}

.block-comparison-table th,
.block-comparison-table td {
    padding: 12px 16px;
}

/* ==========================================
   Comparison Slider Block
   ========================================== */
.block-comparison-slider {
    margin: 16px 0;
    border-radius: 12px;
    overflow: hidden;
    user-select: none;
}

.block-comparison-slider .slider-before {
    transition: none;
}

.block-comparison-slider .slider-divider {
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

/* Unsplash attribution on last screen — small footer per Unsplash API guidelines */
.unsplash-attribution {
    margin-top: 24px;
    padding: 8px 16px;
    font-size: 11px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    letter-spacing: 0.02em;
    word-break: break-word;
}
.unsplash-attribution a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.unsplash-attribution a:hover {
    color: rgba(255, 255, 255, 0.85);
}
/* Light backgrounds — invert tone for legibility */
.screen[data-bg-tone="light"] .unsplash-attribution,
.screen.is-light-bg .unsplash-attribution {
    color: rgba(0, 0, 0, 0.45);
}
.screen[data-bg-tone="light"] .unsplash-attribution a:hover,
.screen.is-light-bg .unsplash-attribution a:hover {
    color: rgba(0, 0, 0, 0.75);
}

/* Crawlable-but-hidden flow transcript (SEO). NOT display:none so Google and
   screen readers still receive the text; clipped off-screen so it never
   affects the full-viewport player layout. */
.flow-transcript.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;
}
