/*
 * Custom styles — loaded after the Tailwind CDN.
 * Xyris XR brand-level overrides and utilities.
 */

html {
    scroll-behavior: smooth;
}

body {
    /* Fallback before Google Fonts load; matches the Tailwind theme. */
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Selection colour in brand pink. */
::selection {
    background: #E8637A;
    color: #ffffff;
}

/*
 * Content-block rich text (PG-01002). Sanitised HTML from content_blocks.rich_text
 * is rendered with th:utext inside .prose-block. Colours are inherited from the
 * block wrapper's inline text-color, so we only set sizing/spacing here.
 */
.prose-block {
    line-height: 1.7;
}
.prose-block h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    line-height: 1.15;
    margin: 0.4em 0 0.4em;
}
.prose-block h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: clamp(1.25rem, 2vw, 1.6rem);
    margin: 0.6em 0 0.3em;
}
.prose-block p {
    margin: 0.75em 0;
    font-size: 1.075rem;
}
.prose-block ul,
.prose-block ol {
    margin: 0.75em 0;
    padding-left: 1.5em;
}
.prose-block ul { list-style: disc; }
.prose-block ol { list-style: decimal; }
.prose-block li { margin: 0.3em 0; }
.prose-block a {
    color: #E8637A;
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
}
.prose-block a:hover {
    color: #4ADE80;
}
/* Allow a TEXT block to express a CTA as a styled link/button via the editor's
   link tool — links inside the rich text already render in brand pink above. */

/* ===========================================================================
 * The LOET — comic reader (PG-01005, UC-04002)
 * Pure-CSS panel grids + overlaid narration boxes / speech / thought bubbles.
 * ===========================================================================*/

/* Episode-list cover placeholder: comic-style diagonal hatching. */
.loet-cover-placeholder {
    background-color: #15123A;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.05) 0,
        rgba(255, 255, 255, 0.05) 2px,
        transparent 2px,
        transparent 12px
    );
}

/* --- Page grids (one per layout_template) --------------------------------- */
.loet-page {
    display: grid;
    gap: 8px;
    background: #ffffff;
    padding: 8px;
    border-radius: 10px;
}
.layout-single {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}
.layout-two-horizontal {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}
.layout-two-vertical {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
}
.layout-three-top-wide {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
/* slot 0 spans the wide top row */
.layout-three-top-wide > .loet-panel:nth-child(1) {
    grid-column: 1 / span 2;
}
.layout-three-bottom-wide {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
/* slot 2 spans the wide bottom row */
.layout-three-bottom-wide > .loet-panel:nth-child(3) {
    grid-column: 1 / span 2;
}
.layout-four-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* --- Panel slot ----------------------------------------------------------- */
.loet-panel {
    position: relative;
    overflow: hidden;
    border: 3px solid #111;
    border-radius: 6px;
    background: #e9e9ef;
    aspect-ratio: 4 / 3;
}
.layout-single .loet-panel {
    aspect-ratio: 16 / 9;
}
.loet-panel-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* Grey placeholder with comic hatching when a slot has no image. */
.loet-panel-placeholder {
    width: 100%;
    height: 100%;
    background-color: #c9c9d2;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(0, 0, 0, 0.08) 0,
        rgba(0, 0, 0, 0.08) 3px,
        transparent 3px,
        transparent 14px
    );
}

/* --- Text elements: shared ------------------------------------------------ */
.loet-text-el {
    position: absolute;
    max-width: 70%;
    z-index: 2;
    font-family: 'Comic Neue', 'Comic Sans MS', cursive, sans-serif;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
}
.loet-text-content {
    display: inline-block;
}

/* --- NARRATION: rectangular caption box anchored to an edge --------------- */
.loet-text-el.narration {
    max-width: 80%;
    background: rgba(20, 18, 40, 0.85);
    color: #fff;
    padding: 5px 9px;
    border-radius: 3px;
    font-size: clamp(0.62rem, 1.6vw, 0.85rem);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.narration.text-top    { top: 6px; left: 50%; transform: translateX(-50%); text-align: center; }
.narration.text-bottom { bottom: 6px; left: 50%; transform: translateX(-50%); text-align: center; }
.narration.text-left   { left: 6px; top: 50%; transform: translateY(-50%); max-width: 45%; }
.narration.text-right  { right: 6px; top: 50%; transform: translateY(-50%); max-width: 45%; }

/* --- SPEECH bubble: white rounded shape with a solid triangular tail ------ */
.loet-text-el.speech {
    background: #fff;
    color: #111;
    border: 2.5px solid #111;
    padding: 7px 11px;
    border-radius: 18px;
    font-size: clamp(0.62rem, 1.6vw, 0.85rem);
    max-width: 60%;
}
.loet-text-el.speech::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 9px solid transparent;
}
/* Tail direction points inward, derived from the bubble's position. */
.speech.bubble-top-left::after,
.speech.bubble-top-center::after,
.speech.bubble-top-right::after {
    top: 100%;
    left: 24px;
    border-top-color: #111;
    border-bottom: 0;
    margin-top: -2px;
}
.speech.bubble-middle-left::after,
.speech.bubble-middle-center::after,
.speech.bubble-middle-right::after {
    top: 100%;
    left: 24px;
    border-top-color: #111;
    border-bottom: 0;
    margin-top: -2px;
}
.speech.bubble-bottom-left::after,
.speech.bubble-bottom-center::after,
.speech.bubble-bottom-right::after {
    bottom: 100%;
    left: 24px;
    border-bottom-color: #111;
    border-top: 0;
    margin-bottom: -2px;
}

/* --- THOUGHT bubble: cloud-ish oval with a chain of dots ------------------ */
.loet-text-el.thought {
    background: #fff;
    color: #111;
    border: 2.5px solid #111;
    padding: 9px 14px;
    border-radius: 50% / 45%;
    font-size: clamp(0.62rem, 1.6vw, 0.85rem);
    max-width: 58%;
}
/* Two diminishing dots leading away from the bubble (thought "tail"). */
.loet-text-el.thought::before,
.loet-text-el.thought::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #111;
}
.loet-text-el.thought::before {
    width: 12px;
    height: 12px;
}
.loet-text-el.thought::after {
    width: 6px;
    height: 6px;
}
/* top-* thoughts trail upward; everything else trails downward. */
.thought.bubble-top-left::before,
.thought.bubble-top-center::before,
.thought.bubble-top-right::before { top: 100%; left: 18px; margin-top: 1px; }
.thought.bubble-top-left::after,
.thought.bubble-top-center::after,
.thought.bubble-top-right::after { top: 100%; left: 14px; margin-top: 16px; }

.thought.bubble-middle-left::before,
.thought.bubble-middle-center::before,
.thought.bubble-middle-right::before,
.thought.bubble-bottom-left::before,
.thought.bubble-bottom-center::before,
.thought.bubble-bottom-right::before { bottom: 100%; left: 18px; margin-bottom: 1px; }
.thought.bubble-middle-left::after,
.thought.bubble-middle-center::after,
.thought.bubble-middle-right::after,
.thought.bubble-bottom-left::after,
.thought.bubble-bottom-center::after,
.thought.bubble-bottom-right::after { bottom: 100%; left: 14px; margin-bottom: 16px; }

/* --- Bubble grid positions (9-point) -------------------------------------- */
.bubble-top-left      { top: 8px;  left: 8px; }
.bubble-top-center    { top: 8px;  left: 50%; transform: translateX(-50%); }
.bubble-top-right     { top: 8px;  right: 8px; }
.bubble-middle-left   { top: 50%;  left: 8px;  transform: translateY(-50%); }
.bubble-middle-center { top: 50%;  left: 50%;  transform: translate(-50%, -50%); }
.bubble-middle-right  { top: 50%;  right: 8px; transform: translateY(-50%); }
.bubble-bottom-left   { bottom: 8px; left: 8px; }
.bubble-bottom-center { bottom: 8px; left: 50%; transform: translateX(-50%); }
.bubble-bottom-right  { bottom: 8px; right: 8px; }

/* Mobile: collapse multi-column comic layouts to a single column. */
@media (max-width: 640px) {
    .layout-two-horizontal,
    .layout-three-top-wide,
    .layout-three-bottom-wide,
    .layout-four-grid {
        grid-template-columns: 1fr;
        grid-template-rows: none;
    }
    .layout-three-top-wide > .loet-panel:nth-child(1),
    .layout-three-bottom-wide > .loet-panel:nth-child(3) {
        grid-column: auto;
    }
}

/* Custom scrollbar on the dark theme (WebKit). */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
::-webkit-scrollbar-track {
    background: #15123A;
}
::-webkit-scrollbar-thumb {
    background: #3a356b;
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: #E8637A;
}
