/* Import monospace font for certain text elements */
@import url('https://fonts.googleapis.com/css2?family=Fira+Mono:wght@400;500;700&display=swap');

/* Custom font for headlines */
@font-face {
    font-family: 'Inter Display';
    src: url(font/InterDisplay-SemiBold.woff2);
}

/* Base styles */
:root {
    /* Colors */
    --background-color: #E8E8E6;
    --line-color: #D1CFCF;
    --highlight-color: #CCFF5F;
    --text-color: #1D1D1D;
    --text-gray: #909090;
    
    /* Typography */
    --font-heading: 'Inter Display', sans-serif;
    --font-body: 'Fira Mono', monospace;
    
    /* Font Sizes */
    --font-size-h1: 56px;
    --font-size-h2: 20px;
    --font-size-h3: 20px;
    --font-size-h4: 20px;
    --font-size-p: 20px;
    --font-size-small: 12px;
    
    /* Grid */
    --line-height: 40px;      /* Height between background lines */
    --content-left: 25%;      /* Left margin for content */
    --padding-top: 60px;      /* Top padding for first element */
    
    /* Indentation for h3, h4, and p */
    --indent-desktop: 32px;   /* Indentation for desktop */
    --indent-mobile: 32px;    /* Indentation for mobile and tablet */
}

/* Reset and ensure consistent box model */
html, body {
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    overflow-y: auto; /* Always enable scrolling for legal page */
}

/* Layout */
.container {
    width: 100%;
    position: relative;
    min-height: 100vh;
}

/* Background lines */
.background-lines {
    position: absolute;
    top: 0;
    left: var(--content-left);
    width: calc(100% - var(--content-left));
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        var(--line-color) 0px,
        var(--line-color) 1px,
        transparent 1px,
        transparent var(--line-height)
    );
    pointer-events: none;
    z-index: 0;
}

/* Content wrapper */
.content {
    position: relative;
    z-index: 10;
    padding-left: calc(var(--content-left) + 12px);
    padding-right: 40px;
    padding-bottom: var(--line-height);
}

/* Base grid system for consistent alignment */
.grid-baseline {
    display: block;
    position: relative;
    margin: 0;
    padding: 0;
    min-height: var(--line-height);
    /* No margin-bottom here to prevent extra space */
}

/* Ensure text is positioned correctly on the baseline */
.text-baseline {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    line-height: 1;
}

/* Add this class to your HTML elements */
.heading-h1 {
    font-family: var(--font-heading);
    font-size: var(--font-size-h1);
    padding-top: var(--padding-top);
    height: calc(var(--line-height) * 2); /* Fixed height for proper spacing */
    margin-bottom: 33px; /* Set to 30px as requested */
}

.heading-h2 {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--font-size-h2);
    height: var(--line-height); /* Fixed height for proper spacing */
    margin-top: var(--line-height);
    padding: 0;
}

.heading-h3 {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--font-size-h3);
    height: var(--line-height); /* Fixed height for proper spacing */
    margin-top: var(--line-height);
    padding: 0 0 0 var(--indent-desktop);
}

.heading-h4 {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--font-size-h4);
    height: var(--line-height); /* Fixed height for proper spacing */
    margin-top: var(--line-height);
    padding: 0 0 0 var(--indent-desktop);
}

.paragraph {
    font-family: var(--font-body);
    font-size: var(--font-size-p);
    /* Allow paragraphs to expand based on content */
    min-height: var(--line-height);
    /* Set line height to ensure text aligns with grid */
    line-height: var(--line-height); 
    /* If there are multiple lines of text, add margin-bottom for spacing */
    margin-bottom: var(--line-height);
    padding: 0 0 0 var(--indent-desktop);
}

/* Adjust paragraph that follows immediately after headings */
.heading-h1 + .paragraph,
.heading-h2 + .paragraph,
.heading-h3 + .paragraph,
.heading-h4 + .paragraph {
    margin-top: 0;
}

/* Same for actual heading elements */
h1 + p,
h2 + p,
h3 + p,
h4 + p {
    margin-top: 0;
}

/* Heading styles */
h1 {
    font-family: var(--font-heading);
    font-size: var(--font-size-h1);
    line-height: calc(var(--line-height) * 2);
    padding-top: var(--padding-top);
    margin: 0 0 33px 0; /* Set to 30px as requested */
    font-weight: 500;
}

h2 {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--font-size-h2);
    line-height: var(--line-height);
    margin: var(--line-height) 0 0 0;
    padding: 0;
}

h3 {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--font-size-h3);
    line-height: var(--line-height);
    margin: var(--line-height) 0 0 0;
    padding: 0 0 0 var(--indent-desktop);
}

h4 {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--font-size-h4);
    line-height: var(--line-height);
    margin: var(--line-height) 0 0 0;
    padding: 0 0 0 var(--indent-desktop);
}

/* Adjust spacing for heading-to-heading sequences */
h1 + h2,
h2 + h3,
h3 + h4 {
    margin-top: 0; /* Remove double spacing between consecutive headings */
}

/* Paragraph styles */
p {
    font-family: var(--font-body);
    font-size: var(--font-size-p);
    line-height: var(--line-height);
    margin: 0 0 var(--line-height) 0;
    padding: 0 0 0 var(--indent-desktop);
}

/* Special handling for multi-line text in .text-baseline */
.paragraph .text-baseline {
    position: static; /* Override absolute for paragraph text */
    display: block;
    line-height: var(--line-height);
}

/* List styles */
ul, ol {
    font-family: var(--font-body);
    font-size: var(--font-size-p);
    margin: 0 0 var(--line-height) 0;
    padding: 0 0 0 calc(20px + var(--indent-desktop));
}

li {
    line-height: var(--line-height);
    margin: 0;
    padding: 0;
}

/* Legal links styles */
.legal-links {
    position: relative;
    left: 0;
    margin-top: calc(var(--line-height) * 2);
    margin-bottom: var(--line-height);
}

.legal-links a {
    font-family: var(--font-body);
    font-size: var(--font-size-small);
    color: var(--text-gray);
    line-height: var(--line-height);
}

/* Link styles */
a {
    color: var(--text-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Responsive layouts */


@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --content-left: 0;
        --indent-desktop: var(--indent-mobile);
    }
    
    .content {
        padding-left: 24px;
        padding-right: 24px;
    }
    
    .legal-links {
        left: 24px;
    }

    .background-lines {
        left: 0;
        width: 100%;
    }
    
    h3, h4, p {
        padding-left: var(--indent-mobile);
    }
    
    ul, ol {
        padding-left: calc(20px + var(--indent-mobile));
    }
}

@media (max-width: 768px) {
    :root {
        --content-left: 0;
        --padding-top: 49px;
        --font-size-h1: 32px;
        --font-size-h2: 18px;
        --font-size-h3: 18px;
        --font-size-h4: 16px;
        --font-size-p: 16px;
        --indent-desktop: var(--indent-mobile);
    }
    
    .content {
        padding-left: 16px;
        padding-right: 16px;
    }

    h1 {
        line-height: var(--line-height);
        margin-bottom: 45px; /* Reduced spacing for mobile */
    }
    
    .heading-h1 {
        margin-bottom: 45px; /* Reduced spacing for mobile */
    }

    h2 {
        line-height: calc(var(--line-height) - 0px);
    }

    h3 {
        line-height: calc(var(--line-height) - 0px);
        padding-left: var(--indent-mobile);
    }
    
    h4 {
        line-height: calc(var(--line-height) - 0px);
        padding-left: var(--indent-mobile);
    }
    
    p {
        line-height: calc(var(--line-height) - 0px);
        padding-left: var(--indent-mobile);
    }
    
    ul, ol {
        padding-left: calc(20px + var(--indent-mobile));
    }
    
    .legal-links {
        left: 16px;
    }

    .background-lines {
        left: 0;
        width: 100%;
    }
}

/* Add rule for <br> tags to enforce line height */
br {
    display: block;
    content: "";
    margin-top: var(--line-height); /* Ensure it takes up exactly one line */
    line-height: var(--line-height);
}

/* Debug helper */
.debug-grid h1, .debug-grid h2, .debug-grid h3, .debug-grid h4, 
.debug-grid p, .debug-grid li, .debug-grid .legal-links {
    background: rgba(255, 0, 0, 0.05);
    border: 1px dashed rgba(255, 0, 0, 0.3);
}