/**
 * Shared styles for Puck components.
 * Used both in the editor (React) and copied to static folder for public pages.
 */

/* ========================================
   Base Variables & Tokens
   ======================================== */
:root {
    /* Colors */
    --puck-primary: #3b82f6;
    --puck-primary-hover: #2563eb;
    --puck-secondary: #6b7280;
    --puck-secondary-hover: #4b5563;
    --puck-text-dark: #1f2937;
    --puck-text-light: #ffffff;
    --puck-text-muted: #6b7280;
    --puck-bg-white: #ffffff;
    --puck-bg-light: #f9fafb;
    --puck-bg-dark: #1f2937;
    --puck-border: #e5e7eb;

    /* Font sizes – responsive, scaled relative to 1920px reference width.
       clamp(min, preferred vw, max at 1920px) */
    --puck-text-sm: clamp(0.75rem, 0.729vw, 0.875rem);
    --puck-text-base: clamp(0.875rem, 0.833vw, 1rem);
    --puck-text-lg: clamp(0.938rem, 0.938vw, 1.125rem);
    --puck-text-xl: clamp(1rem, 1.042vw, 1.25rem);
    --puck-text-2xl: clamp(1.125rem, 1.25vw, 1.5rem);
    --puck-text-3xl: clamp(1.25rem, 1.563vw, 1.875rem);
    --puck-text-4xl: clamp(1.5rem, 1.875vw, 2.25rem);
    --puck-text-5xl: clamp(1.75rem, 2.5vw, 3rem);
    --puck-text-6xl: clamp(2rem, 3.125vw, 3.75rem);

    /* Transitions */
    --puck-transition: all 0.2s ease;
}

/* ========================================
   Heading Component
   ======================================== */
.puck-heading {
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

/* ========================================
   Text / RichText Component
   ======================================== */
.puck-richtext {
    line-height: 1.6;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

/* Force font-size inheritance: browser defaults for h1-h6/p
   override parent class size. We reset them so .text-xl etc.
   on the wrapper actually controls the rendered size. */
.puck-richtext h1,
.puck-richtext h2,
.puck-richtext h3,
.puck-richtext h4,
.puck-richtext h5,
.puck-richtext h6,
.puck-richtext p {
    font-size: inherit;
    line-height: inherit;
}

/* ========================================
   Tailwind-compatible size classes
   ======================================== */
.puck-render .text-sm {
    font-size: var(--puck-text-sm);
}

.puck-render .text-base {
    font-size: var(--puck-text-base);
}

.puck-render .text-lg {
    font-size: var(--puck-text-lg);
}

.puck-render .text-xl {
    font-size: var(--puck-text-xl);
}

.puck-render .text-2xl {
    font-size: var(--puck-text-2xl);
}

.puck-render .text-3xl {
    font-size: var(--puck-text-3xl);
}

.puck-render .text-4xl {
    font-size: var(--puck-text-4xl);
}

.puck-render .text-5xl {
    font-size: var(--puck-text-5xl);
}

.puck-render .text-6xl {
    font-size: var(--puck-text-6xl);
}

/* Colors */
.text-white {
    color: #ffffff;
}

.text-black {
    color: #000000;
}

.text-gray-700 {
    color: #374151;
}

.text-gray-800 {
    color: #1f2937;
}

.text-gray-300 {
    color: #d1d5db;
}

.text-blue-500 {
    color: #3b82f6;
}

.text-blue-600 {
    color: #2563eb;
}

.text-yellow-400 {
    color: #facc15;
}

/* Font weights */
.font-light {
    font-weight: 300;
}

.font-normal {
    font-weight: 400;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

/* Alignment */
.text-left {
    text-align: left;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* ========================================
   Image Component
   ======================================== */
.puck-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
}

.puck-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--puck-bg-light);
    border-radius: 8px;
    color: var(--puck-text-muted);
    min-width: 200px;
    min-height: 150px;
}

/* ========================================
   Video Component
   ======================================== */
.puck-video {
    max-width: 100%;
    border-radius: 8px;
}

.puck-video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--puck-bg-dark);
    border-radius: 8px;
    color: var(--puck-text-muted);
    min-height: 200px;
}

/* ========================================
   Button Component
   ======================================== */
.puck-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    padding: 0.75rem 1.5rem;
    transition: var(--puck-transition);
}

.puck-button:hover {
    opacity: 0.9;
}

.puck-button--primary {
    background-color: var(--puck-primary);
    color: var(--puck-text-light);
    border: none;
}

.puck-button--primary:hover {
    background-color: var(--puck-primary-hover);
}

.puck-button--outline {
    background-color: transparent;
    color: var(--puck-primary);
    border: 2px solid var(--puck-primary);
}

.puck-button--outline:hover {
    background-color: var(--puck-primary);
    color: var(--puck-text-light);
}

.puck-button--ghost {
    background-color: transparent;
    color: var(--puck-primary);
    border: none;
}

.puck-button--ghost:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

/* ========================================
   Container (Section) Component
   ======================================== */
.puck-container {
    padding-left: 1rem;
    padding-right: 1rem;
}

.puck-container__inner {
    margin: 0 auto;
}

/* Padding Y classes */
.py-0 {
    padding-top: 0;
    padding-bottom: 0;
}

.py-4 {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.py-8 {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.py-12 {
    padding-top: 3rem;
    padding-bottom: 3rem;
}

.py-16 {
    padding-top: 4rem;
    padding-bottom: 4rem;
}

.py-20 {
    padding-top: 5rem;
    padding-bottom: 5rem;
}

/* Max width classes */
.max-w-sm {
    max-width: 24rem;
}

.max-w-md {
    max-width: 28rem;
}

.max-w-lg {
    max-width: 32rem;
}

.max-w-xl {
    max-width: 36rem;
}

.max-w-2xl {
    max-width: 42rem;
}

.max-w-3xl {
    max-width: 48rem;
}

.max-w-4xl {
    max-width: 56rem;
}

.max-w-5xl {
    max-width: 64rem;
}

.max-w-6xl {
    max-width: 72rem;
}

.max-w-7xl {
    max-width: 80rem;
}

.w-full {
    max-width: 100%;
}

.container {
    max-width: 100%;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

/* ========================================
   Spacer Component
   ======================================== */
.puck-spacer {
    display: block;
}

/* ========================================
   Files Component
   ======================================== */
.puck-files {
    list-style: none;
    padding: 0;
    margin: 0;
}

.puck-files__title {
    font-size: var(--puck-text-xl);
    font-weight: 600;
    margin-bottom: 1rem;
}

.puck-files__item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--puck-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.puck-files__icon {
    font-size: 1.25rem;
}

.puck-files__link {
    color: var(--puck-primary);
    text-decoration: none;
}

.puck-files__link:hover {
    text-decoration: underline;
}

/* ========================================
   Table Component
   ======================================== */
.puck-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--puck-text-sm);
    margin: 1rem 0;
}

.puck-table th,
.puck-table td {
    padding: 0.75rem;
    text-align: left;
}

.puck-table th {
    background-color: var(--puck-bg-light);
    font-weight: 600;
    border-bottom: 2px solid var(--puck-border);
}

.puck-table--bordered th,
.puck-table--bordered td {
    border: 1px solid var(--puck-border);
}

.puck-table--striped tbody tr:nth-child(even) {
    background-color: var(--puck-bg-light);
}

/* Hero children must not exceed viewport */
.puck-hero,
.puck-hero>* {
    box-sizing: border-box;
    max-width: 100vw;
}

/* ========================================
   Responsive: Tablet + Mobile (≤1024px)
   Same rules for both — no difference between
   tablet and mobile behavior.
   ======================================== */
@media (max-width: 1024px) {
    :root {
        --puck-text-sm: 0.75rem;
        --puck-text-base: 0.875rem;
        --puck-text-lg: 1rem;
        --puck-text-xl: 1.1rem;
        --puck-text-2xl: 1.25rem;
        --puck-text-3xl: 1.375rem;
        --puck-text-4xl: 1.5rem;
        --puck-text-5xl: 1.75rem;
        --puck-text-6xl: 2rem;
    }

    /* Hero layout */
    .puck-hero {
        position: relative !important;
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    .puck-hero>img,
    .puck-hero>video {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    .puck-hero>div[style*="background-image"],
    .puck-hero>div[style*="background:"],
    .puck-hero>div[style*="background-color:rgba"] {
        position: absolute !important;
        inset: 0 !important;
    }

    .puck-hero>div[style*="z-index:2"],
    .puck-hero>div[style*="z-index: 2"] {
        position: relative !important;
        z-index: 2 !important;
        box-sizing: border-box !important;
        max-width: 100% !important;
        min-height: 300px;
        padding: 2rem 1rem !important;
    }

    /* Heading / text sizes */
    .puck-heading.text-6xl {
        font-size: 2rem !important;
    }

    .puck-heading.text-5xl {
        font-size: 1.75rem !important;
    }

    .puck-heading.text-4xl {
        font-size: 1.5rem !important;
    }

    .puck-heading.text-3xl {
        font-size: 1.375rem !important;
    }

    .puck-richtext.text-xl {
        font-size: 1rem !important;
    }

    .puck-richtext.text-2xl {
        font-size: 1.125rem !important;
    }

    /* Cap margins */
    [style*="margin-left:calc"],
    [style*="margin-right:calc"] {
        margin-left: min(1rem, 4vw) !important;
        margin-right: min(1rem, 4vw) !important;
    }

    [style*="margin-top:calc"],
    [style*="margin-bottom:calc"] {
        margin-top: min(1rem, 4vh) !important;
        margin-bottom: min(1rem, 4vh) !important;
    }

    /* Text wrapping */
    .puck-richtext,
    .puck-heading {
        word-break: break-word;
    }

    /* Grid layouts: stack */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .puck-container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* ========================================
   Responsive: Extra-small (≤340px)
   ======================================== */
@media (max-width: 340px) {
    .puck-heading.text-6xl {
        font-size: 1.5rem !important;
    }

    .puck-heading.text-5xl {
        font-size: 1.375rem !important;
    }

    .puck-heading.text-4xl {
        font-size: 1.25rem !important;
    }

    .puck-heading.text-3xl {
        font-size: 1.125rem !important;
    }

    .puck-heading.text-2xl {
        font-size: 1rem !important;
    }

    .puck-richtext.text-xl {
        font-size: 0.875rem !important;
    }

    .puck-richtext.text-2xl {
        font-size: 1rem !important;
    }

    .puck-richtext.text-lg {
        font-size: 0.875rem !important;
    }

    .puck-richtext.text-base {
        font-size: 0.8125rem !important;
    }
}

:root {
    --puck-text-3xl: 1.5rem;
    --puck-text-4xl: 1.75rem;
    --puck-text-5xl: 2rem;
    --puck-text-6xl: 2.5rem;
}

.puck-hero {
    position: relative !important;
    min-height: auto !important;
    height: auto !important;
    overflow: visible !important;
}

/* Background image/video fills the hero */
.puck-hero>img,
.puck-hero>video {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Background & overlay divs stay absolutely positioned */
.puck-hero>div[style*="background-image"],
.puck-hero>div[style*="background:"],
.puck-hero>div[style*="background-color:rgba"] {
    position: absolute !important;
    inset: 0 !important;
}

/* Content wrapper: relative so it provides height to the section */
.puck-hero>div[style*="z-index:2"],
.puck-hero>div[style*="z-index: 2"] {
    position: relative !important;
    z-index: 2 !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    min-height: 300px;
    padding: 2rem 1rem !important;
}

/* Responsive heading sizes for DefaultPage (no .puck-render wrapper) */
.puck-heading.text-6xl {
    font-size: 2rem !important;
}

.puck-heading.text-5xl {
    font-size: 1.75rem !important;
}

.puck-heading.text-4xl {
    font-size: 1.5rem !important;
}

.puck-heading.text-3xl {
    font-size: 1.375rem !important;
}

.puck-richtext.text-xl {
    font-size: 1rem !important;
}

.puck-richtext.text-2xl {
    font-size: 1.125rem !important;
}
}

/* ========================================
   Responsive: Mobile (≤768px)
   ======================================== */
@media (max-width: 768px) {
    :root {
        --puck-text-sm: 0.75rem;
        --puck-text-base: 0.875rem;
        --puck-text-lg: 1rem;
        --puck-text-xl: 1.1rem;
        --puck-text-2xl: 1.25rem;
        --puck-text-3xl: 1.375rem;
        --puck-text-4xl: 1.5rem;
        --puck-text-5xl: 1.75rem;
        --puck-text-6xl: 2rem;
    }

    /* Responsive heading sizes — mobile */
    .puck-heading.text-6xl {
        font-size: 2rem !important;
    }

    .puck-heading.text-5xl {
        font-size: 1.75rem !important;
    }

    .puck-heading.text-4xl {
        font-size: 1.5rem !important;
    }

    .puck-heading.text-3xl {
        font-size: 1.375rem !important;
    }

    .puck-richtext.text-xl {
        font-size: 1rem !important;
    }

    .puck-richtext.text-2xl {
        font-size: 1.125rem !important;
    }

    /* Cap margins on mobile — prevent huge calc() values */
    [style*="margin-left:calc"],
    [style*="margin-right:calc"] {
        margin-left: min(1rem, 4vw) !important;
        margin-right: min(1rem, 4vw) !important;
    }

    [style*="margin-top:calc"],
    [style*="margin-bottom:calc"] {
        margin-top: min(1rem, 4vh) !important;
        margin-bottom: min(1rem, 4vh) !important;
    }

    /* Ensure text wraps on narrow screens */
    .puck-richtext,
    .puck-heading {
        word-break: break-word;
    }

    /* Grid layouts: stack on mobile */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .puck-container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* ========================================
   Responsive: Extra-small (≤340px)
   ======================================== */
@media (max-width: 340px) {
    .puck-heading.text-6xl {
        font-size: 1.5rem !important;
    }

    .puck-heading.text-5xl {
        font-size: 1.375rem !important;
    }

    .puck-heading.text-4xl {
        font-size: 1.25rem !important;
    }

    .puck-heading.text-3xl {
        font-size: 1.125rem !important;
    }

    .puck-heading.text-2xl {
        font-size: 1rem !important;
    }

    .puck-richtext.text-xl {
        font-size: 0.875rem !important;
    }

    .puck-richtext.text-2xl {
        font-size: 1rem !important;
    }

    .puck-richtext.text-lg {
        font-size: 0.875rem !important;
    }

    .puck-richtext.text-base {
        font-size: 0.8125rem !important;
    }
}