/* Guest-facing styles for legacy (Filament 3 / awcodes/filament-tiptap-editor)
   rich content: gridBuilder, tiptapBlock cards and youtube embeds.
   Ported from the old app's resources/css/tiptap.css — only the rules the
   guest renderer needs. Plain CSS (no theme()/@apply) so it compiles
   identically inside app.css (Tailwind v4). */

/* -------------------------------------------------------------------------- */
/* Grid builder                                                                */
/* -------------------------------------------------------------------------- */

.filament-tiptap-grid-builder {
    display: grid;
    gap: 1rem;
    box-sizing: border-box;
}

.filament-tiptap-grid-builder .filament-tiptap-grid-builder__column {
    box-sizing: border-box;
    padding: 0.5rem;
    border-radius: 0.25rem;
}

.filament-tiptap-grid-builder .filament-tiptap-grid-builder__column > * + * {
    margin-block-start: 1rem;
}

/* Responsive stacking: collapse the grid to one column at the chosen
   breakpoint or smaller. `!important` beats the inline
   `grid-template-columns` emitted by the legacy node. */
@media (max-width: 640px) {
    .filament-tiptap-grid-builder[data-stack-at="sm"] {
        grid-template-columns: 1fr !important;
    }

    .filament-tiptap-grid-builder[data-stack-at="sm"] .filament-tiptap-grid-builder__column {
        grid-column: span 1 !important;
    }
}

@media (max-width: 768px) {
    .filament-tiptap-grid-builder[data-stack-at="md"] {
        grid-template-columns: 1fr !important;
    }

    .filament-tiptap-grid-builder[data-stack-at="md"] .filament-tiptap-grid-builder__column {
        grid-column: span 1 !important;
    }
}

@media (max-width: 1024px) {
    .filament-tiptap-grid-builder[data-stack-at="lg"] {
        grid-template-columns: 1fr !important;
    }

    .filament-tiptap-grid-builder[data-stack-at="lg"] .filament-tiptap-grid-builder__column {
        grid-column: span 1 !important;
    }
}

/* Programmes page: swap the column order of odd grids on mobile so the text
   column leads. `nth-child(... of ...)` counts only grid elements. */
@media (max-width: 768px) {
    .programs-page .filament-tiptap-grid-builder:nth-child(odd of .filament-tiptap-grid-builder) .filament-tiptap-grid-builder__column:first-child {
        order: 2;
    }

    .programs-page .filament-tiptap-grid-builder:nth-child(odd of .filament-tiptap-grid-builder) .filament-tiptap-grid-builder__column:last-child {
        order: 1;
    }
}

/* -------------------------------------------------------------------------- */
/* Legacy insert-card block                                                    */
/* -------------------------------------------------------------------------- */

.tiptap-editor .tiptap-card,
.ProseMirror .tiptap-card {
    margin-block: 2rem;
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    padding: 10px 15px;
}

.tiptap-editor .tiptap-card .tiptap-card-content,
.ProseMirror .tiptap-card .tiptap-card-content {
    width: 100%;
}

.tiptap-editor .tiptap-card .tiptap-card-content > * + *,
.ProseMirror .tiptap-card .tiptap-card-content > * + * {
    margin-block-start: 1rem;
}

.tiptap-editor .tiptap-card .tiptap-card-content p,
.tiptap-editor .tiptap-card .tiptap-card-content ul,
.tiptap-editor .tiptap-card .tiptap-card-content ol,
.tiptap-editor .tiptap-card .tiptap-card-content h1,
.tiptap-editor .tiptap-card .tiptap-card-content h2,
.tiptap-editor .tiptap-card .tiptap-card-content h3,
.tiptap-editor .tiptap-card .tiptap-card-content h4,
.tiptap-editor .tiptap-card .tiptap-card-content h5,
.tiptap-editor .tiptap-card .tiptap-card-content h6,
.ProseMirror .tiptap-card .tiptap-card-content p,
.ProseMirror .tiptap-card .tiptap-card-content ul,
.ProseMirror .tiptap-card .tiptap-card-content ol,
.ProseMirror .tiptap-card .tiptap-card-content h1,
.ProseMirror .tiptap-card .tiptap-card-content h2,
.ProseMirror .tiptap-card .tiptap-card-content h3,
.ProseMirror .tiptap-card .tiptap-card-content h4,
.ProseMirror .tiptap-card .tiptap-card-content h5,
.ProseMirror .tiptap-card .tiptap-card-content h6 {
    color: inherit !important;
    margin-top: 0 !important;
    padding: 4px !important;
}

.tiptap-editor .tiptap-card .tiptap-card-content p:last-child,
.ProseMirror .tiptap-card .tiptap-card-content p:last-child {
    margin-bottom: 0;
}

.tiptap-editor .tiptap-card .tiptap-card-content p,
.ProseMirror .tiptap-card .tiptap-card-content p {
    font-size: 20px !important;
    line-height: 1.25 !important;
    padding: 6px !important;
}

/* -------------------------------------------------------------------------- */
/* YouTube embeds (minimal — the guest page x-init adds the rounded corners)   */
/* -------------------------------------------------------------------------- */

.tiptap-editor [data-youtube-video],
.ProseMirror [data-youtube-video] {
    position: relative;
}

.tiptap-editor [data-youtube-video] iframe,
.ProseMirror [data-youtube-video] iframe {
    border: 0;
    display: block;
}

/* -------------------------------------------------------------------------- */
/* fastFadeIn (old tiptap.css lines 3-15)                                      */
/* -------------------------------------------------------------------------- */

@keyframes fastFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.tiptap-editor,
.ProseMirror {
    animation: fastFadeIn 0.5s both;
}

/* -------------------------------------------------------------------------- */
/* Legacy typography layer (old tiptap.css lines 114-272, 348-371).            */
/* Values are the Tailwind v3 literals behind the old @apply utilities.        */
/* `!important` is required where pasted inline styles or app.css's later      */
/* generic typography section (same specificity, later source order) would     */
/* otherwise win — without it the old computed values are not restored.        */
/* -------------------------------------------------------------------------- */

.tiptap-editor > * + *,
.ProseMirror > * + * {
    margin-block-start: 1rem !important;
}

.tiptap-editor > * + h1,
.ProseMirror > * + h1,
.tiptap-editor > * + h2,
.ProseMirror > * + h2,
.tiptap-editor > * + h3,
.ProseMirror > * + h3,
.tiptap-editor > * + h4,
.ProseMirror > * + h4,
.tiptap-editor > * + h5,
.ProseMirror > * + h5,
.tiptap-editor > * + h6,
.ProseMirror > * + h6 {
    margin-block-start: 2rem !important;
}

.tiptap-editor h1,
.ProseMirror h1,
.tiptap-editor h2,
.ProseMirror h2,
.tiptap-editor h3,
.ProseMirror h3,
.tiptap-editor h4,
.ProseMirror h4,
.tiptap-editor h5,
.ProseMirror h5,
.tiptap-editor h6,
.ProseMirror h6 {
    font-weight: bold;
}

/* h1 = text-4xl md:text-5xl lg:text-6xl lg:leading-snug mb-0 !important */
.tiptap-editor h1,
.ProseMirror h1 {
    font-size: 2.25rem !important;
    line-height: 2.5rem !important;
    margin-bottom: 0 !important;
}

@media (min-width: 768px) {
    .tiptap-editor h1,
    .ProseMirror h1 {
        font-size: 3rem !important;
        line-height: 1 !important;
    }
}

@media (min-width: 1024px) {
    .tiptap-editor h1,
    .ProseMirror h1 {
        font-size: 3.75rem !important;
        line-height: 1.375 !important;
    }
}

/* h2 = text-3xl md:text-4xl lg:text-[2.9rem] lg:leading-snug mb-0 !important */
.tiptap-editor h2,
.ProseMirror h2 {
    font-size: 1.875rem !important;
    line-height: 2.25rem !important;
    margin-bottom: 0 !important;
}

@media (min-width: 768px) {
    .tiptap-editor h2,
    .ProseMirror h2 {
        font-size: 2.25rem !important;
        line-height: 2.5rem !important;
    }
}

@media (min-width: 1024px) {
    .tiptap-editor h2,
    .ProseMirror h2 {
        font-size: 2.9rem !important;
        line-height: 1.375 !important;
    }
}

/* h3 = text-2xl lg:text-4xl lg:leading-relaxed */
.tiptap-editor h3,
.ProseMirror h3 {
    font-size: 1.5rem !important;
    line-height: 2rem !important;
}

@media (min-width: 1024px) {
    .tiptap-editor h3,
    .ProseMirror h3 {
        font-size: 2.25rem !important;
        line-height: 1.625 !important;
    }
}

/* h4 = text-xl lg:text-3xl lg:leading-normal */
.tiptap-editor h4,
.ProseMirror h4 {
    font-size: 1.25rem !important;
    line-height: 1.75rem !important;
}

@media (min-width: 1024px) {
    .tiptap-editor h4,
    .ProseMirror h4 {
        font-size: 1.875rem !important;
        line-height: 1.5 !important;
    }
}

/* h5 = text-lg lg:text-2xl lg:leading-tight */
.tiptap-editor h5,
.ProseMirror h5 {
    font-size: 1.125rem !important;
    line-height: 1.75rem !important;
}

@media (min-width: 1024px) {
    .tiptap-editor h5,
    .ProseMirror h5 {
        font-size: 1.5rem !important;
        line-height: 1.25 !important;
    }
}

/* h6/p/ul/ol/blockquote/pre/table/div/a = text-base lg:text-2xl lg:leading-8 */
.tiptap-editor h6,
.ProseMirror h6,
.tiptap-editor p,
.ProseMirror p,
.tiptap-editor ul,
.ProseMirror ul,
.tiptap-editor ol,
.ProseMirror ol,
.tiptap-editor blockquote,
.ProseMirror blockquote,
.tiptap-editor pre,
.ProseMirror pre,
.tiptap-editor table,
.ProseMirror table,
.tiptap-editor div,
.ProseMirror div,
.tiptap-editor a,
.ProseMirror a {
    font-size: 1rem !important;
    line-height: 1.5rem !important;
}

@media (min-width: 1024px) {
    .tiptap-editor h6,
    .ProseMirror h6,
    .tiptap-editor p,
    .ProseMirror p,
    .tiptap-editor ul,
    .ProseMirror ul,
    .tiptap-editor ol,
    .ProseMirror ol,
    .tiptap-editor blockquote,
    .ProseMirror blockquote,
    .tiptap-editor pre,
    .ProseMirror pre,
    .tiptap-editor table,
    .ProseMirror table,
    .tiptap-editor div,
    .ProseMirror div,
    .tiptap-editor a,
    .ProseMirror a {
        font-size: 1.5rem !important;
        line-height: 2rem !important;
    }
}

.tiptap-editor p,
.ProseMirror p {
    margin-top: 1rem !important;
}

/* -------------------------------------------------------------------------- */
/* Lists (old tiptap.css lines 181-218)                                        */
/* -------------------------------------------------------------------------- */

.tiptap-editor ul,
.ProseMirror ul,
.tiptap-editor ol,
.ProseMirror ol {
    padding-inline-start: 0 !important;
    margin-inline-start: 1.5rem;
    margin-top: 1rem !important;
    margin-bottom: 0 !important;
}

.tiptap-editor ul,
.ProseMirror ul {
    list-style: disc;
}

.tiptap-editor ol,
.ProseMirror ol {
    list-style: decimal;
}

.tiptap-editor ul.checked-list,
.ProseMirror ul.checked-list {
    list-style-type: none;
    margin-inline-start: 0;
}

.tiptap-editor ul.checked-list li,
.ProseMirror ul.checked-list li {
    display: flex;
    align-items: baseline;
    gap: 0.375em;
}

.tiptap-editor ul.checked-list li::before,
.ProseMirror ul.checked-list li::before {
    content: '\2713';
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.tiptap-editor ul li p,
.ProseMirror ul li p {
    margin: 0 !important;
}

/* -------------------------------------------------------------------------- */
/* Blockquote, hr, links, sup/small, lead (old tiptap.css lines 220-275)       */
/* -------------------------------------------------------------------------- */

.tiptap-editor blockquote,
.ProseMirror blockquote {
    border-left: 0.25rem solid #9ca3af;
    padding-inline-start: 0.5rem;
    margin-inline-start: 1rem;
    font-size: 1.25rem !important;
    font-style: normal !important;
}

.tiptap-editor hr,
.ProseMirror hr {
    border-color: #9ca3af;
}

.tiptap-editor a,
.ProseMirror a {
    color: #2563eb;
}

.tiptap-editor a[id],
.ProseMirror a[id] {
    color: #000000;
    text-decoration: none;
}

.tiptap-editor a[id]::before,
.ProseMirror a[id]::before {
    content: '# ';
    color: #6b7280;
    opacity: 0.5;
}

.tiptap-editor sup,
.ProseMirror sup {
    font-size: 65%;
}

.tiptap-editor small,
.ProseMirror small {
    font-size: 0.75rem;
}

.tiptap-editor .lead,
.ProseMirror .lead {
    font-size: 1.375rem !important;
    line-height: 1.3 !important;
}

/* -------------------------------------------------------------------------- */
/* Code / pre (old tiptap.css lines 348-363)                                   */
/* -------------------------------------------------------------------------- */

.tiptap-editor pre,
.ProseMirror pre {
    padding: 0.75rem 1rem;
    border-radius: 0.25rem;
    font-size: 0.875rem !important;
}

.tiptap-editor pre code,
.ProseMirror pre code {
    border-radius: 0;
    padding-inline: 0;
}

.tiptap-editor code,
.ProseMirror code {
    background-color: #d1d5db;
    border-radius: 0.25rem;
    padding-inline: 0.25rem;
}

/* -------------------------------------------------------------------------- */
/* Tables (old tiptap.css lines 279-342)                                       */
/* -------------------------------------------------------------------------- */

.tiptap-editor table,
.ProseMirror table {
    border-collapse: collapse;
    margin: 0;
    overflow: hidden;
    table-layout: fixed;
    width: 100%;
    position: relative;
}

.tiptap-editor table td,
.ProseMirror table td,
.tiptap-editor table th,
.ProseMirror table th {
    border: 1px solid #9ca3af;
    min-width: 1em;
    padding: 3px 5px;
    vertical-align: top;
    background-clip: padding-box;
}

.tiptap-editor table td > *,
.ProseMirror table td > *,
.tiptap-editor table th > *,
.ProseMirror table th > * {
    margin-bottom: 0;
}

.tiptap-editor table th,
.ProseMirror table th {
    background-color: #e5e7eb;
    color: #374151;
    font-weight: 700;
    text-align: left;
}

.tiptap-editor table p,
.ProseMirror table p {
    margin: 0;
}

.tiptap-editor .tableWrapper,
.ProseMirror .tableWrapper {
    padding: 1rem 0;
    overflow-x: auto;
}

/* Editor-only table cell selection + column resize handles (old tiptap.css
   lines 309-333) — skipped in the guest copy. */

.tiptap-editor table .selectedCell,
.ProseMirror table .selectedCell {
    position: relative;
}

.tiptap-editor table .selectedCell:after,
.ProseMirror table .selectedCell:after {
    background: rgba(200, 200, 255, 0.4);
    content: "";
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
    position: absolute;
    z-index: 2;
}

.tiptap-editor table .column-resize-handle,
.ProseMirror table .column-resize-handle {
    background-color: #adf;
    bottom: -2px;
    position: absolute;
    right: -2px;
    pointer-events: none;
    top: 0;
    width: 4px;
}
