/* =============================================================================
   Bluebook Citation Generator - Styles
   Modern Academic Design
   ============================================================================= */

:root {
    --primary: #2d3748;
    --primary-light: #4a5568;
    --accent: #9b2c2c;
    --accent-light: #c53030;
    --bg: #faf9f7;
    --card-bg: #ffffff;
    --text: #1a202c;
    --text-light: #718096;
    --text-muted: #a0aec0;
    --border: #e2e8f0;
    --border-light: #edf2f7;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 10px 40px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Source Serif 4', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
}

/* Back link styling */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-light);
    text-decoration: none;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    margin-bottom: 2rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem 0.5rem 0.5rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.back-link:hover {
    color: var(--primary);
    background: var(--border-light);
}

.back-link svg {
    opacity: 0.7;
}

/* =============================================================================
   Header
   ============================================================================= */

header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-top: 1rem;
}

header h1 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

header .header-logo {
    height: 2.5rem;
    width: auto;
    display: block;
}

/* Non-selectable logo title on home page */
header h1.logo-title {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Logo text animation - typewriter effect */
.logo-text-container {
    position: relative;
    display: inline-block;
    text-align: left;
}

.logo-text {
    white-space: nowrap;
    display: inline-block;
}

/* Typing cursor */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--primary);
    margin-left: 2px;
    opacity: 0;
    vertical-align: text-bottom;
    animation: none;
}

.typing-cursor.visible {
    opacity: 1;
}

.typing-cursor.blinking {
    animation: blink 0.6s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Clickable logo link on subpages */
header .logo-link {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    color: inherit;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

header .logo-link:hover {
    opacity: 0.8;
}

header .subtitle {
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

header .header-nav {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.25rem;
}

/* Utility link in top right corner - positioned within container */
.utility-nav {
    display: flex;
    justify-content: flex-end;
    margin-bottom: -2rem; /* Pull up the header content */
}

.utility-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    background: var(--card-bg);
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.utility-link:hover {
    background: var(--border-light);
    color: var(--primary);
    border-color: var(--primary-light);
}

.utility-link .link-text {
    display: inline;
}

@media (max-width: 600px) {
    .utility-nav {
        margin-bottom: -1.5rem;
    }
    
    .utility-link {
        padding: 0.5rem;
    }
    
    .utility-link .link-text {
        display: none;
    }
}

header .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    background: var(--card-bg);
    color: var(--primary);
    border: 1px solid var(--border);
    text-decoration: none;
    border-radius: var(--radius);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

header .nav-link:hover {
    background: var(--border-light);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* Legacy support for secondary class - now same as default */
header .nav-link.secondary {
    background: var(--card-bg);
    color: var(--primary);
    border: 1px solid var(--border);
}

header .nav-link.secondary:hover {
    background: var(--border-light);
    border-color: var(--primary-light);
}

/* Legacy support for single search link */
header .search-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding: 0.7rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

header .search-link:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* =============================================================================
   Tabs
   ============================================================================= */

.tabs {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1.5rem;
    position: relative;
    padding: 0.25rem;
    background: var(--border-light);
    border-radius: var(--radius-lg);
    max-width: 100%;
}

/* Sliding indicator - positioned absolutely */
.tabs-indicator {
    position: absolute;
    height: calc(100% - 0.5rem);
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
    top: 0.25rem;
    left: 0.25rem;
}

.tab {
    position: relative;
    z-index: 1;
    padding: 0.75rem 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    transition: color 0.2s ease;
    letter-spacing: 0.01em;
    white-space: nowrap;
    flex-shrink: 0;
    border-radius: var(--radius);
}

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

.tab.active {
    color: var(--primary);
}

/* Mobile optimizations */
@media (max-width: 600px) {
    .tabs {
        gap: 0;
        padding: 0.2rem;
        border-radius: var(--radius);
        background: var(--border-light);
    }
    
    .tabs-scroll {
        gap: 0.125rem;
    }

    .tab {
        padding: 0.65rem 0.9rem;
        font-size: 0.85rem;
    }

    .tabs-indicator {
        top: 0.2rem;
        height: calc(100% - 0.4rem);
    }
}

/* Tab Dropdown */
.tab-dropdown {
    position: relative;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dropdown-trigger svg {
    transition: transform 0.2s;
}

.tab-dropdown.open .dropdown-trigger svg {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 0.5rem;
    z-index: 100;
    display: none;
}

.tab-dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 6px;
    letter-spacing: 0.01em;
}

.dropdown-item:hover {
    background: var(--bg);
    color: var(--primary);
}

.dropdown-item.active {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

/* =============================================================================
   Source Search Dropdown
   ============================================================================= */

.tabs-scroll {
    display: flex;
    gap: 0.25rem;
    flex: 1;
    min-width: 0; /* Allow flex item to shrink below content size */
    overflow-x: scroll;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.tabs-scroll .tab {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.75rem 1rem; /* Slightly smaller padding to fit more tabs */
}


.tabs-scroll::-webkit-scrollbar {
    display: none;
}

.source-search-dropdown {
    position: relative;
    flex-shrink: 0;
    margin-left: 0.25rem;
}

.source-search-backdrop {
    display: none;
}

.source-search-trigger {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.75rem 0.9rem !important;
}

.source-count {
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    padding: 0.15rem 0.4rem;
    min-width: 1.1rem;
    text-align: center;
}

.source-search-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    min-width: 280px;
    max-width: 320px;
    z-index: 200;
    display: none;
    overflow: hidden;
}

.source-search-dropdown.open .source-search-menu {
    display: block;
}

.source-search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.source-search-input-wrapper svg {
    color: var(--text-light);
    flex-shrink: 0;
}

.source-search-input {
    flex: 1;
    border: none;
    background: none;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    color: var(--text);
    outline: none;
}

.source-search-input::placeholder {
    color: var(--text-light);
}

.source-search-results {
    max-height: 320px;
    overflow-y: auto;
    padding: 0.5rem;
}

.source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: none;
    background: none;
    text-align: left;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.source-item:hover {
    background: var(--bg);
    color: var(--primary);
}

.source-item.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.source-item.hidden {
    display: none;
}

.source-name {
    flex: 1;
}

.source-ref {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 400;
}

.source-item:hover .source-ref {
    color: var(--primary-light);
}

/* Subtype styling */
.source-subtype {
    position: relative; /* Required for ::before positioning */
    padding-left: 2rem;
    font-weight: 400;
    font-size: 0.85rem;
}

.source-subtype::before {
    content: '';
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.5rem;
    height: 1px;
    background: var(--border);
}

.source-subtype .source-name {
    color: var(--text-light);
}

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

.has-subtypes {
    margin-bottom: 0;
}

.source-search-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Drag handle - hidden on desktop, shown on mobile */
.source-search-drag-handle {
    display: none;
}

/* Mobile adjustments for source search - bottom sheet style */
@media (max-width: 600px) {
    /* When dropdown is open, hide the entire tabs area behind the backdrop */
    .source-search-dropdown.open {
        z-index: 201;
    }
    
    /* The tabs indicator should be hidden when search is open */
    .tabs:has(.source-search-dropdown.open) .tabs-indicator,
    .source-search-dropdown.open + .tabs-indicator {
        opacity: 0 !important;
        visibility: hidden;
    }
    
    .source-search-menu {
        position: fixed;
        top: auto;
        bottom: 0 !important;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        max-width: none;
        min-width: 100%;
        max-height: 70svh;
        transform: translateY(0);
        transition: transform 0.3s ease, max-height 0.15s ease;
        flex-direction: column;
        background: #ffffff;
        z-index: 9999;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
        /* Keep display: none by default - only show when open */
    }
    
    .source-search-dropdown.open .source-search-menu {
        display: flex !important;
    }
    
    /* Drag handle for swipe-to-dismiss */
    .source-search-drag-handle {
        display: block;
        width: 40px;
        height: 5px;
        background: var(--text-muted);
        border-radius: 3px;
        margin: 10px auto 6px;
        cursor: grab;
        flex-shrink: 0;
    }
    
    .source-search-results {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 0.5rem 1rem;
    }
    
    /* Input wrapper stays at top */
    .source-search-input-wrapper {
        flex-shrink: 0;
        border-radius: 0;
        background: #ffffff;
        padding: 0.75rem 1rem;
    }
    
    .source-search-backdrop {
        display: none;
    }
    
    .source-search-dropdown.open .source-search-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 199;
    }
}

/* =============================================================================
   Forms
   ============================================================================= */

.forms-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}

.citation-form {
    display: none;
}

.citation-form.active {
    display: block;
}

.citation-form h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.rule-ref {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.form-row {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.form-row.two-col {
    grid-template-columns: 1fr 1fr;
}

.form-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 600px) {
    .form-row.two-col,
    .form-row.three-col {
        grid-template-columns: 1fr;
    }

    .forms-container {
        padding: 1.25rem;
        border-radius: var(--radius);
    }

    .citation-form h2 {
        font-size: 1.3rem;
        flex-wrap: wrap;
    }

    header h1 {
        font-size: 2rem;
    }

    header .subtitle {
        font-size: 0.85rem;
    }

    header .header-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    header .nav-link {
        justify-content: center;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    transition: all 0.2s ease;
    background: #fafafa;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(45, 55, 72, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.form-group textarea {
    resize: vertical;
    min-height: 3.75rem;
}

.suggest-container {
    position: relative;
}

.cfr-title-selector {
    position: relative;
    width: 100%;
}

/* Match USC/CFR title dropdown UI used on /search */
.form-group .cfr-title-input {
    width: 100%;
    padding: 0.75rem 1rem; /* keep consistent with other form inputs */
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fafafa;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-group .cfr-title-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(45, 55, 72, 0.1);
}

.form-group .cfr-title-input.has-value {
    background: #f8fafc;
}

.cfr-title-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
}

.cfr-title-dropdown.open {
    display: block;
}

.cfr-title-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

.cfr-title-option:last-child {
    border-bottom: none;
}

.cfr-title-option:hover,
.cfr-title-option.active {
    background: #f7fafc;
}

.cfr-title-option.selected {
    background: #ebf8ff;
}

.cfr-title-option-name {
    flex: 1;
    color: var(--text);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
}

.cfr-title-option-abbrev {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.cfr-title-option-all {
    font-style: italic;
    color: var(--text-light);
}

.journal-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-height: 280px;
    overflow-y: auto;
}

.journal-option {
    padding: 0.65rem 1rem;
    cursor: pointer;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    transition: background 0.1s ease;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
}

.journal-option:hover {
    background: var(--bg);
}

.journal-option.active {
    background: rgba(45, 55, 72, 0.08);
}

.journal-option .journal-abbrev {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.form-group .hint {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    font-style: italic;
}

.generate-btn,
.sample-btn {
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: var(--radius);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 0.75rem;
    margin-top: 1rem;
    letter-spacing: 0.02em;
}

.generate-btn {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow);
}

.generate-btn:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

/* URL Lookup Section */
.url-lookup-section {
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.url-input-row {
    display: flex;
    gap: 0.5rem;
}

.url-input-row input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
}

.lookup-btn {
    padding: 0.6rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.2s;
    white-space: nowrap;
}

.lookup-btn:hover {
    background: var(--primary-light);
}

.lookup-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.lookup-status {
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.lookup-status.loading {
    color: var(--text-light);
}

.lookup-status.success {
    color: #38a169;
}

.lookup-status.error {
    color: var(--accent);
}

.form-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.sample-btn {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
}

.sample-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--text-muted);
}

/* Custom Select Styling */
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-group select:hover {
    border-color: var(--primary-light);
}

/* Custom Court Selector */
.court-selector-wrapper {
    position: relative;
}

.court-selector-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    background: #fafafa;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    text-align: left;
}

.court-selector-btn:hover {
    border-color: var(--primary-light);
    background: white;
}

.court-selector-btn.active {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(45, 55, 72, 0.1);
}

.court-selector-btn .placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.court-selector-btn svg {
    color: var(--text-light);
    transition: transform 0.2s ease;
}

.court-selector-btn.active svg {
    transform: rotate(180deg);
}

.court-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-height: 350px;
    overflow-y: auto;
    display: none;
}

.court-dropdown.open {
    display: block;
    animation: dropdownSlide 0.15s ease;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.court-dropdown-header {
    padding: 0.75rem 1rem;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
    position: sticky;
    top: 0;
}

.court-dropdown-section {
    padding: 0.5rem 0;
}

.court-dropdown-section-title {
    padding: 0.5rem 1rem;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.court-option {
    padding: 0.65rem 1rem;
    cursor: pointer;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    transition: background 0.1s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.court-option:hover {
    background: var(--bg);
}

.court-option.selected {
    background: rgba(45, 55, 72, 0.08);
    color: var(--primary);
}

.court-option .court-abbrev {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.court-custom-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.court-custom-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 55, 72, 0.1);
}

.court-custom-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* =============================================================================
   Output Section
   ============================================================================= */

.output-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.output-section h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.context-toggle {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.context-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.context-toggle input[type="radio"] {
    accent-color: var(--primary);
}

.output-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.output-box.secondary {
    background: #fff;
    border-style: dashed;
}

.output-box.plain {
    background: #1a202c;
    border: none;
}

.output-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.output-box.plain .output-label {
    color: #a0aec0;
}

/* =============================================================================
   Citation Typography - THE IMPORTANT PART!
   ============================================================================= */

.citation-output {
    font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--text);
    min-height: 1.5em;
}

.citation-output.plain-text {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.9rem;
    color: #e2e8f0;
    word-break: break-all;
}

/* Case names, article titles, book titles - ITALICS */
.citation-output em,
.citation-output .case-name,
.citation-output .title,
.citation-output .signal,
.citation-output .history,
.formatted-citation em,
.formatted-citation .title {
    font-style: italic;
}

/* Author names, journal names, constitution - SMALL CAPS */
.citation-output .small-caps,
.formatted-citation .small-caps {
    font-variant: small-caps;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* URLs */
.citation-output .url {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.85em;
    color: var(--primary-light);
    word-break: break-all;
}

/* Empty state */
.citation-output:empty::before {
    content: 'Your citation will appear here...';
    color: #a0aec0;
    font-style: italic;
}

/* Copy buttons in output section */
.output-box .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--border-light);
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.35rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    opacity: 0;
    transition: all 0.2s ease;
}

.output-box:hover .copy-btn {
    opacity: 1;
}

.output-box .copy-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.output-box .copy-btn.copied {
    background: #48bb78;
    border-color: #48bb78;
    color: white;
    opacity: 1;
}

/* Plain text box copy button - always visible with different styling */
.output-box.plain .copy-btn {
    opacity: 1;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #a0aec0;
    padding: 0.4rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.output-box.plain .copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* =============================================================================
   Validation Issues
   ============================================================================= */

.validation-issues {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.validation-issues .output-label {
    color: var(--accent);
}

.validation-issues ul {
    list-style: none;
    font-size: 0.9rem;
}

.validation-issues li {
    padding: 0.25rem 0;
    color: #c53030;
}

.validation-issues li::before {
    content: '⚠ ';
}

/* =============================================================================
   Footer
   ============================================================================= */

footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

footer p {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}

footer .disclaimer {
    font-size: 0.8rem;
}

/* Dictionary-style definition */
footer .ibid-definition {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

footer .ibid-definition .term {
    font-weight: 600;
    font-style: italic;
    color: var(--text-light);
}

footer .ibid-definition .pronunciation {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    margin-left: 0.25rem;
}

footer .ibid-definition .part-of-speech {
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 0.35rem;
}

footer .ibid-definition .definition-text {
    display: block;
    margin-top: 0.25rem;
    padding-left: 1rem;
    text-indent: -0.5rem;
    font-style: normal;
}

footer .ibid-definition .definition-text::before {
    content: "1.";
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 0.35rem;
}

footer .ibid-definition .etymology {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    display: block;
    margin-top: 0.35rem;
}

footer .copyright {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

footer a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* =============================================================================
   Print Styles
   ============================================================================= */

@media print {
    .tabs,
    .forms-container,
    .context-toggle,
    .copy-btn,
    footer {
        display: none;
    }

    .output-section {
        box-shadow: none;
        padding: 0;
    }

    .citation-output {
        font-size: 12pt;
    }
}

/* =============================================================================
   View Transitions API - Page Navigation Animations
   ============================================================================= */

/* Enable view transitions */
@view-transition {
    navigation: auto;
}

/* Sequential fade: old out first, then new in */
::view-transition-old(root) {
    animation: fade-out 0.15s ease-out forwards;
    z-index: 1;
}

::view-transition-new(root) {
    animation: fade-in 0.15s ease-in 0.1s forwards;
    opacity: 0;
    z-index: 0;
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =============================================================================
   Custom Date Picker
   ============================================================================= */

.date-picker {
    position: relative;
    display: inline-block;
    width: 100%;
}

.date-picker-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.95rem;
    width: 100%;
    transition: all 0.2s;
    color: var(--text);
    cursor: text;
}

.date-picker-btn:hover {
    border-color: var(--primary-light);
}

.date-picker-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 32, 44, 0.1);
}

.date-picker-btn.has-value {
    color: var(--text);
}

.date-picker-btn:not(.has-value) {
    color: var(--text-light);
}

.date-picker-btn svg {
    margin-left: auto;
    opacity: 0.5;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.date-picker-btn svg:hover {
    opacity: 0.8;
}

.date-picker-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    color: var(--text);
    outline: none;
    min-width: 0;
}

.date-picker-input::placeholder {
    color: var(--text-light);
}

.date-picker-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 280px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    padding: 0.75rem;
}

.date-picker-dropdown.open {
    display: block;
}

.date-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.date-picker-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.date-picker-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.15s;
}

.date-picker-nav-btn:hover {
    background: var(--border-light);
    color: var(--text);
}

.date-picker-month-year {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: color 0.15s;
    background: none;
    border: none;
    padding: 0;
    font-family: 'Inter', -apple-system, sans-serif;
}

.date-picker-month-year:hover {
    color: var(--primary);
}

.date-picker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 0.25rem;
}

.date-picker-weekday {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-light);
    padding: 0.25rem;
    font-family: 'Inter', -apple-system, sans-serif;
}

.date-picker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.date-picker-day {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text);
    transition: all 0.15s;
}

.date-picker-day:hover:not(.other-month):not(.selected) {
    background: var(--border-light);
}

.date-picker-day.other-month {
    color: var(--text-muted);
}

.date-picker-day.today {
    font-weight: 600;
    color: var(--primary);
}

.date-picker-day.selected {
    background: var(--primary);
    color: white;
}

.date-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.date-picker-grid-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.25rem;
    border: none;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text);
    transition: all 0.15s;
}

.date-picker-grid-item:hover {
    background: var(--border-light);
}

.date-picker-grid-item.current {
    font-weight: 600;
    color: var(--primary);
}

.date-picker-grid-item.selected {
    background: var(--primary);
    color: white;
}

.date-picker-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.date-picker-action {
    padding: 0.35rem 0.75rem;
    border: none;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--primary);
    transition: all 0.15s;
}

.date-picker-action:hover {
    background: var(--border-light);
}

/* =============================================================================
   Google Sign-In & User Menu
   ============================================================================= */

/* Google Sign-In Button */
.google-signin-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.google-signin-btn:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.google-signin-btn.large {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
}

.google-icon {
    flex-shrink: 0;
}

/* Hide "Sign in" text on mobile */
@media (max-width: 600px) {
    .google-signin-btn .signin-text {
        display: none;
    }
    
    .google-signin-btn {
        padding: 0.5rem;
    }
    
    .google-signin-btn.large {
        padding: 0.75rem 1.5rem;
    }
    
    .google-signin-btn.large .signin-text {
        display: inline;
    }
}

/* User Menu */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Invisible bridge to keep hover active when moving to dropdown */
.user-menu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: border-color 0.2s;
}

.user-avatar:hover {
    border-color: var(--primary);
}

.user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--border);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-5px);
    transition: all 0.2s;
    z-index: 1000;
}

/* Show dropdown on hover (desktop) or when .active class is set (touch/click) */
.user-menu:hover .user-dropdown,
.user-menu.active .user-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.user-info {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.user-name {
    display: block;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.user-email {
    display: block;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.user-dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s;
}

.user-dropdown-item:hover {
    background: var(--border-light);
}

/* Login Required Page */
.login-required {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
}

.login-required-content {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.login-icon {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.login-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.login-subtitle {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

/* Utility Nav - position at top right */
.utility-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
}
