/**
 * Casalmar - WordPress Block Theme CSS Reset
 * Modern reset for FSE/Block themes (2025)
 *
 * Based on best practices from:
 * - WordPress Gutenberg guidelines
 * - Modern CSS Reset principles
 * - Block theme specificity considerations
 *
 * Uses :root :where() for low specificity where appropriate,
 * allowing theme.json and user styles to override.
 */

/* ===========================================
   Hide legacy theme elements
   =========================================== */
.mobile-bottom-bar,
.dt-mobile-menu-icon,
#phantom,
.the7-e-hamburger {
    display: none !important;
    visibility: hidden !important;
}

/* ===========================================
   Box Sizing Reset
   =========================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ===========================================
   Core Element Resets
   =========================================== */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===========================================
   Figure & Image Reset (Critical for WP Blocks)
   =========================================== */
figure {
    margin: 0;
    padding: 0;
}

img,
picture,
video,
canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* SVG - only block display for standalone images, not icons */
svg:not([class*="icon"]):not([class*="vbo"]):not(.fa):not([class*="fa-"]) {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ===========================================
   Typography Reset
   =========================================== */
h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}

p {
    margin: 0;
}

/* ===========================================
   List Reset
   =========================================== */
ul, ol {
    margin: 0;
    padding: 0;
}

/* ===========================================
   Link Reset
   Using :where() for low specificity - allows WP classes to override
   =========================================== */
:where(a) {
    color: inherit;
    text-decoration: inherit;
}

/* ===========================================
   Form Element Reset
   Using :where() for low specificity - allows WP classes to override
   =========================================== */
:where(button),
:where(input),
:where(optgroup),
:where(select),
:where(textarea) {
    font: inherit;
    margin: 0;
    padding: 0;
}

:where(button) {
    cursor: pointer;
}

/* ===========================================
   Table Reset
   =========================================== */
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* ===========================================
   Pre/Code Reset
   =========================================== */
pre {
    margin: 0;
    white-space: pre;
    overflow-x: auto;
}

code {
    font-family: inherit;
}

/* ===========================================
   WordPress Block-Specific Resets
   Uses :where() for low specificity
   =========================================== */

/* Image blocks - force proper sizing */
:root :where(.wp-block-image) {
    margin: 0;
}

:root :where(.wp-block-image figure) {
    margin: 0;
}

:root :where(.wp-block-image img) {
    display: block;
    height: auto;
}

:root :where(.wp-block-image.is-resized) {
    margin: 0;
}

:root :where(.wp-block-image.is-resized img) {
    height: auto;
}

/* Cover block */
:root :where(.wp-block-cover) {
    margin: 0;
}

/* Group blocks */
:root :where(.wp-block-group) {
    margin-block-start: 0;
    margin-block-end: 0;
}

/* Columns */
:root :where(.wp-block-columns) {
    margin-bottom: 0;
}

:root :where(.wp-block-column) {
    margin-bottom: 0;
}

/* Buttons */
:root :where(.wp-block-buttons) {
    margin: 0;
}

:root :where(.wp-block-button) {
    margin: 0;
}

/* Paragraphs in blocks */
:root :where(.wp-block-group p) {
    margin: 0;
}

/* Template parts */
:root :where(.wp-block-template-part) {
    margin: 0;
}

/* Site blocks container */
:root :where(.wp-site-blocks) {
    padding-top: 0 !important;
    padding-block-start: 0 !important;
    margin-top: 0 !important;
    gap: 0 !important;
}

/* Remove gap before footer */
footer,
.wp-block-template-part[data-slug="footer"] {
    margin-top: 0 !important;
    margin-block-start: 0 !important;
}

/* Main content - no bottom margin */
main {
    margin-bottom: 0 !important;
    margin-block-end: 0 !important;
}

/* Remove gap between site blocks on home */
.home .wp-site-blocks {
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.home .wp-site-blocks > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
}

/* Header template part - no external margins */
.home .wp-block-template-part:first-child,
.home header.csm-header-transparent {
    margin: 0 !important;
}

/* Home main content - no spacing */
.home .csm-home-main,
.home main.csm-home-main {
    margin: 0 !important;
    padding: 0 !important;
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
}

/* Hero should start at top */
.home .csm-hero {
    margin-top: 0 !important;
    margin-block-start: 0 !important;
}

/* ===========================================
   Header-Specific Resets (Higher specificity)
   =========================================== */

/* Reset all margins in header */
.csm-header *,
.csm-header-transparent * {
    margin-block-start: 0;
    margin-block-end: 0;
}

/* Header figure/image blocks */
.csm-header .wp-block-image,
.csm-header-transparent .wp-block-image,
.csm-header figure,
.csm-header-transparent figure {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0;
}

/* Header paragraphs */
.csm-header p,
.csm-header-transparent p {
    margin: 0 !important;
    line-height: 1;
}

/* Header groups */
.csm-header .wp-block-group,
.csm-header-transparent .wp-block-group {
    margin: 0 !important;
    padding: 0;
}

/* Header flexbox alignment */
.csm-header .wp-block-group[class*="is-layout-flex"],
.csm-header-transparent .wp-block-group[class*="is-layout-flex"] {
    gap: 0.5rem;
}

/* Force logo container to not grow */
.csm-logo-group.wp-block-group {
    flex-shrink: 0 !important;
}

/* ===========================================
   Accessibility
   =========================================== */
:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Remove focus outline for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
