/* ============================================
   Unhinged Legal Pages - Master Stylesheet
   ============================================ */

/* ----- CSS Reset ----- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ----- CSS Variables ----- */
:root {
    /* Brand Gradient Colors */
    --gradient-purple: rgb(148, 56, 184);      /* #9438B8 */
    --gradient-magenta: rgb(217, 64, 120);     /* #D94078 */
    --gradient-orange-red: rgb(245, 115, 77);  /* #F5734D */
    --gradient-orange: rgb(250, 184, 64);      /* #FAB840 */
    --brand-gradient: linear-gradient(135deg,
        var(--gradient-purple) 0%,
        var(--gradient-magenta) 33%,
        var(--gradient-orange-red) 66%,
        var(--gradient-orange) 100%);

    /* Colors */
    --color-primary: rgb(148, 56, 184);
    --color-primary-hover: rgb(128, 46, 164);
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-background: #ffffff;
    --color-background-alt: #f9fafb;
    --color-border: #e5e7eb;
    --color-success: #10b981;

    /* Typography */
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
                    'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Courier New', monospace;
    --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --text-sm: clamp(0.875rem, 0.825rem + 0.25vw, 1rem);
    --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    --text-lg: clamp(1.125rem, 1.05rem + 0.375vw, 1.375rem);
    --text-xl: clamp(1.25rem, 1.15rem + 0.5vw, 1.625rem);
    --text-2xl: clamp(1.5rem, 1.35rem + 0.75vw, 2rem);
    --text-3xl: clamp(1.875rem, 1.65rem + 1.125vw, 2.5rem);

    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-2xl: 4rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* ----- Base Styles ----- */
html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----- Typography ----- */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    margin-top: 2em;
    margin-bottom: 0.75em;
}

h1:first-child,
h2:first-child,
h3:first-child {
    margin-top: 0;
}

h1 { font-size: var(--text-3xl); font-weight: var(--weight-bold); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

p {
    margin-bottom: 1em;
}

.subtitle {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    font-weight: var(--weight-normal);
}

a {
    color: var(--color-primary);
    text-decoration: underline;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-primary-hover);
}

ul, ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

li {
    margin-bottom: 0.5em;
}

strong {
    font-weight: var(--weight-semibold);
}

code {
    font-family: var(--font-mono);
    background: var(--color-background-alt);
    padding: 0.125em 0.5em;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

/* ----- Layout ----- */
.container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
}

.legal-document {
    max-width: 45rem;
    margin-left: auto;
    margin-right: auto;
}

/* ----- Header ----- */
.site-header {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) 0;
}

.app-name {
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.app-name:hover {
    color: var(--color-primary);
}

.main-nav {
    display: flex;
    gap: var(--spacing-lg);
}

.main-nav a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-weight: var(--weight-medium);
    transition: color 0.2s ease;
    position: relative;
    padding: 0.5rem 0;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--color-primary);
}

.main-nav a.active::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-primary);
}

/* ----- Main Content ----- */
.content {
    padding: var(--spacing-2xl) 0;
    min-height: calc(100vh - 200px);
}

.last-updated {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    margin-bottom: var(--spacing-xl);
    font-style: italic;
}

section {
    margin-bottom: var(--spacing-xl);
}

/* ----- Hero Section ----- */
.hero {
    text-align: center;
    padding: var(--spacing-2xl) 0;
    max-width: 48rem;
    margin: 0 auto;
}

.hero h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    margin-bottom: var(--spacing-md);
}

.hero-subtitle {
    font-size: var(--text-xl);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-xl);
}

.cta-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* ----- Features Section ----- */
.features {
    padding: var(--spacing-2xl) 0;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.feature-card {
    padding: var(--spacing-lg);
    background: var(--color-background-alt);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

.feature-card h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    color: var(--color-primary);
}

.feature-card p {
    margin-bottom: 0;
    color: var(--color-text-secondary);
}

/* ----- Quick Links ----- */
.quick-links {
    padding: var(--spacing-2xl) 0;
}

.link-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.link-card {
    padding: var(--spacing-lg);
    background: var(--color-background);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all 0.2s ease;
}

.link-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.link-card h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    color: var(--color-primary);
}

.link-card p {
    margin-bottom: 0;
    color: var(--color-text-secondary);
}

/* ----- Footer ----- */
.site-footer {
    background: var(--color-background-alt);
    border-top: 1px solid var(--color-border);
    padding: var(--spacing-xl) 0;
    margin-top: var(--spacing-2xl);
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.footer-links {
    display: flex;
    gap: var(--spacing-lg);
}

.footer-links a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--color-primary);
}

/* ----- FAQ Accordion ----- */
.faq-section {
    margin-top: var(--spacing-lg);
}

.faq-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-sm);
    overflow: hidden;
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    cursor: pointer;
    background: var(--color-background);
    font-weight: var(--weight-medium);
    transition: background 0.2s ease;
    user-select: none;
    list-style: none;
}

.faq-question::-webkit-details-marker {
    display: none;
}

.faq-question:hover {
    background: var(--color-background-alt);
}

.faq-question span {
    flex: 1;
}

.faq-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: var(--spacing-sm);
}

details[open] .faq-icon {
    transform: rotate(180deg);
}

.faq-answer {
    padding: 0 var(--spacing-lg) var(--spacing-md) var(--spacing-lg);
    color: var(--color-text-secondary);
}

.faq-answer p:last-child,
.faq-answer ol:last-child,
.faq-answer ul:last-child {
    margin-bottom: 0;
}

/* ----- Forms ----- */
.contact-form {
    max-width: 600px;
    margin: var(--spacing-lg) 0;
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: var(--weight-medium);
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-base);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-note {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-top: var(--spacing-md);
}

/* ----- Buttons ----- */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: var(--weight-medium);
    font-size: var(--text-base);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-primary {
    background: var(--brand-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(148, 56, 184, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(148, 56, 184, 0.4);
    filter: brightness(1.05);
}

/* ----- Back to Top ----- */
.back-to-top {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    width: 48px;
    height: 48px;
    background: var(--brand-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    font-size: var(--text-xl);
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* ----- Accessibility ----- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    z-index: 1000;
}

.skip-link:focus {
    top: 0;
}

*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .container {
        padding-left: var(--spacing-sm);
        padding-right: var(--spacing-sm);
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    .main-nav {
        flex-wrap: wrap;
        gap: var(--spacing-md);
    }

    .main-nav a.active::after {
        display: none;
    }

    .site-footer .container {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents iOS zoom */
    }

    .btn {
        width: 100%;
    }

    .cta-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .feature-grid,
    .link-cards {
        grid-template-columns: 1fr;
    }
}

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

    html {
        scroll-behavior: auto;
    }
}
