/* CSS Variables */
:root {
    --primary-dark: #1a365d;
    --primary: #2c5282;
    --primary-light: #4a90a4;
    --accent: #c9a227;
    --accent-light: #d4af37;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border: #e2e8f0;
    --shadow: rgba(26, 54, 93, 0.1);
    --gradient-primary: linear-gradient(135deg, #1a365d 0%, #2c5282 50%, #4a90a4 100%);
    --gradient-subtle: linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
    --gradient-hero: linear-gradient(135deg, rgba(26, 54, 93, 0.95) 0%, rgba(44, 82, 130, 0.9) 50%, rgba(74, 144, 164, 0.85) 100%);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    line-height: 1.3;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 900px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    order: 2;
}

.logo {
    width: 45px;
    height: 38px;
}

.site-title {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.nav {
    display: flex;
    gap: 2.5rem;
    order: 1;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 0.25rem;
    position: relative;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
    border-radius: 1px;
}

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

.nav-link.active::after,
.nav-link:hover::after {
    width: 100%;
}

/* Main Content */
.main-content {
    margin-top: 70px;
    min-height: calc(100vh - 70px);
}

.section {
    display: none;
    padding: 3rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--gradient-hero);
    border-radius: 20px;
    margin-bottom: 3rem;
    color: white;
}

.hero h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Royal Houses Grid */
.royal-houses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.royal-house-card {
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--border);
}

.royal-house-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(26, 54, 93, 0.15);
}

.card-image {
    height: 180px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.card-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(26, 54, 93, 0.3) 0%, transparent 50%);
}

.card-content {
    padding: 1.25rem;
}

.card-content h3 {
    font-size: 1.4rem;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.card-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* House Detail Section */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    margin-bottom: 2rem;
    transition: color 0.3s ease;
}

.back-btn:hover {
    color: var(--primary-dark);
}

.house-header {
    text-align: center;
    margin-bottom: 2rem;
}

.house-header h2 {
    font-size: 2.5rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.house-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Tabs */
.house-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(44, 82, 130, 0.05);
}

.tab-btn.active {
    color: var(--primary);
    background: rgba(44, 82, 130, 0.1);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* House Info */
#house-info {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

#house-info h3 {
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin: 2rem 0 1rem;
}

#house-info h3:first-child {
    margin-top: 0;
}

#house-info p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

#house-info ul {
    list-style: none;
    padding-left: 0;
}

#house-info li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

#house-info li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

/* Family Tree - Modern Focus Navigation */
.family-tree-container {
    background: var(--gradient-subtle);
    border-radius: 16px;
    padding: 1.5rem;
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

/* Breadcrumb Navigation */
.tree-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: 10px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px var(--shadow);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.breadcrumb-item:hover {
    background: var(--primary-light);
    background: rgba(74, 144, 164, 0.1);
    color: var(--primary);
}

.breadcrumb-item.current {
    color: var(--primary-dark);
    font-weight: 600;
    cursor: default;
}

.breadcrumb-item.current:hover {
    background: transparent;
}

.breadcrumb-separator {
    color: var(--border);
    font-size: 0.75rem;
}

.breadcrumb-home {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Focus View Layout */
.tree-focus-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 1rem;
}

/* Tree Rows */
.tree-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

/* Parents Row */
.tree-parents-row {
    margin-bottom: 0;
}

.tree-parent-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.85;
}

.tree-parent-card:hover {
    opacity: 1;
    transform: translateY(-3px);
}

.tree-parent-card .card-inner {
    width: 100px;
    background: var(--surface);
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 3px 12px var(--shadow);
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.tree-parent-card:hover .card-inner {
    border-color: var(--primary-light);
    box-shadow: 0 6px 20px var(--shadow);
}

.tree-parent-card.monarch .card-inner {
    border-color: var(--accent);
}

.tree-parent-card .card-image {
    width: 100%;
    height: 100px;
    background-size: cover;
    background-position: center top;
    background-color: #e2e8f0;
    border-radius: 10px 10px 0 0;
}

.tree-parent-card .card-info {
    padding: 0.5rem;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-parent-card .card-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-dark);
    line-height: 1.2;
}

.tree-parent-card .card-relation {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Connectors */
.tree-connector {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    position: relative;
}

.tree-connector::before {
    content: '';
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary-light), var(--primary));
    opacity: 0.4;
}

.tree-connector-parents::before {
    background: linear-gradient(to bottom, var(--primary), var(--primary-light));
}

.tree-connector.hidden {
    display: none;
}

/* Focus Row - Main Person + Spouse */
.tree-focus-row {
    padding: 1rem 0;
}

.tree-focus-couple {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.tree-focus-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tree-focus-card.main-focus {
    cursor: default;
}

.tree-focus-card.spouse-card:hover {
    transform: scale(1.02);
}

.tree-focus-card .card-inner {
    width: 160px;
    background: var(--surface);
    border-radius: 16px;
    overflow: visible;
    box-shadow: 0 8px 30px var(--shadow);
    border: 3px solid var(--primary);
    transition: all 0.3s ease;
}

.tree-focus-card.spouse-card .card-inner {
    width: 120px;
    border: 2px dashed var(--primary-light);
    box-shadow: 0 4px 15px var(--shadow);
    overflow: visible;
}

.tree-focus-card.spouse-card:hover .card-inner {
    border-color: var(--primary);
    border-style: solid;
}

.tree-focus-card.monarch .card-inner {
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(201, 162, 39, 0.25);
}

.tree-focus-card .card-image {
    width: 100%;
    height: 180px;
    background-size: cover;
    background-position: center top;
    background-color: #e2e8f0;
    position: relative;
    border-radius: 13px 13px 0 0;
}

.tree-focus-card.spouse-card .card-image {
    height: 130px;
    border-radius: 10px 10px 0 0;
}

.tree-focus-card.monarch .card-image::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='%23c9a227' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 16L3 5l5.5 5L12 4l3.5 6L21 5l-2 11H5z'/%3E%3C/svg%3E");
    background-size: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.tree-focus-card .card-info {
    padding: 1rem;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-focus-card.spouse-card .card-info {
    padding: 0.75rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-focus-card .card-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.tree-focus-card.spouse-card .card-name {
    font-size: 0.9rem;
}

.tree-focus-card .card-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.tree-focus-card.spouse-card .card-title {
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
}

.tree-focus-card .card-dates {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
}

.tree-focus-card.spouse-card .card-dates {
    font-size: 0.7rem;
}

/* Marriage connector */
.tree-marriage-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.tree-marriage-line {
    width: 30px;
    height: 2px;
    background: var(--accent);
}

.tree-marriage-icon {
    font-size: 0.8rem;
}

/* Skilte ektefeller */
.tree-marriage-connector.divorced .tree-marriage-line {
    background: transparent;
    border-top: 2px dashed #999;
    height: 0;
}

.divorced-label {
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--surface);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    border: 1px dashed #ccc;
}

.tree-focus-card.divorced {
    opacity: 0.85;
}

.tree-focus-card.divorced .card-inner {
    border: 2px dashed #ccc;
    border-radius: 12px;
    overflow: visible;
}

.tree-focus-card.divorced .card-image {
    border-radius: 10px 10px 0 0;
}

.tree-focus-card.divorced .card-view-btn {
    border-radius: 0 0 10px 10px;
}

.tree-focus-card.divorced::after {
    content: '';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px dashed #999;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Seksjoner for skilte/nåværende ektefeller (desktop) */
.divorced-spouse-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.current-spouse-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Desktop: Horisontal layout for skilte ektefeller */
.tree-focus-couple.has-divorced {
    gap: 0.75rem;
}

/* Mellomstore skjermer */
@media (max-width: 900px) and (min-width: 769px) {
    .tree-focus-card .card-inner {
        width: 140px;
    }

    .tree-focus-card.spouse-card .card-inner {
        width: 100px;
    }

    .tree-focus-couple {
        gap: 1rem;
    }

    .tree-focus-couple.has-divorced {
        gap: 0.5rem;
    }

    .divorced-spouse-section {
        gap: 0.5rem;
    }

    .current-spouse-section {
        gap: 0.75rem;
    }

    .tree-marriage-connector .tree-marriage-line {
        width: 20px;
    }
}

/* Children Row */
.tree-children-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    max-width: 100%;
}

.tree-child-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tree-child-card:hover {
    transform: translateY(-5px);
}

.tree-child-card .card-inner {
    width: 90px;
    background: var(--surface);
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 3px 12px var(--shadow);
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.tree-child-card:hover .card-inner {
    border-color: var(--primary);
    box-shadow: 0 8px 25px var(--shadow);
}

.tree-child-card.monarch .card-inner {
    border-color: var(--accent);
}

.tree-child-card .card-image {
    width: 100%;
    height: 90px;
    background-size: cover;
    background-position: center top;
    background-color: #e2e8f0;
    border-radius: 8px 8px 0 0;
}

.tree-child-card .card-info {
    padding: 0.5rem;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-child-card .card-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-dark);
    line-height: 1.2;
}

.tree-child-card .card-dates {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* More children indicator */
.tree-more-children {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 130px;
    background: var(--surface);
    border-radius: 10px;
    border: 2px dashed var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tree-more-children:hover {
    border-color: var(--primary);
    background: rgba(74, 144, 164, 0.05);
}

.tree-more-children span {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* Generation Info */
.tree-generation-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--shadow);
}

.generation-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.generation-dots {
    display: flex;
    gap: 0.4rem;
}

.generation-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s ease;
}

.generation-dot.active {
    background: var(--primary);
    transform: scale(1.2);
}

.generation-dot.monarch {
    background: var(--accent);
}

/* Empty state */
.tree-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
    text-align: center;
}

.tree-empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* View details button */
.card-view-btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 0 0 13px 13px;
}

.tree-focus-card.spouse-card .card-view-btn {
    border-radius: 0 0 8px 8px;
}

.card-view-btn:hover {
    background: var(--primary-dark);
}

/* Animation for transitions */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tree-focus-view > * {
    animation: fadeIn 0.3s ease-out;
}

/* Responsive - Family Tree Mobile */
@media (max-width: 768px) {
    .tree-focus-card .card-inner {
        width: 110px;
    }

    .tree-focus-card .card-image {
        height: 120px;
    }

    .tree-focus-card.spouse-card .card-inner {
        width: 90px;
    }

    .tree-focus-card.spouse-card .card-image {
        height: 100px;
    }

    .tree-child-card .card-inner {
        width: 70px;
    }

    .tree-child-card .card-image {
        height: 70px;
    }

    .tree-parent-card .card-inner {
        width: 80px;
    }

    .tree-parent-card .card-image {
        height: 80px;
    }

    /* Mobilvisning for par med skilte ektefeller */
    .tree-focus-couple {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
        row-gap: 1rem;
    }

    /* Skilte ektefeller vises i egen rad på mobil */
    .tree-focus-couple.has-divorced {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .tree-focus-couple.has-divorced .divorced-spouse-section {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        background: rgba(150, 150, 150, 0.08);
        border-radius: 12px;
        border: 1px dashed #ccc;
        width: auto;
        justify-content: center;
    }

    .tree-focus-couple.has-divorced .current-spouse-section {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* Skilsmisse-konnektor på mobil */
    .tree-marriage-connector.divorced {
        flex-direction: row;
    }

    .tree-marriage-connector.divorced .tree-marriage-line {
        width: 15px;
    }

    .divorced-label {
        font-size: 0.55rem;
        padding: 0.1rem 0.25rem;
    }

    /* Ekteskapskonnektor på mobil */
    .tree-marriage-connector .tree-marriage-line {
        width: 15px;
    }

    /* Skilt ektefelle-kort på mobil */
    .tree-focus-card.divorced .card-inner {
        width: 80px;
    }

    .tree-focus-card.divorced .card-image {
        height: 90px;
    }
}

/* Veldig små skjermer (under 400px) */
@media (max-width: 400px) {
    .tree-focus-card .card-inner {
        width: 95px;
    }

    .tree-focus-card .card-image {
        height: 100px;
    }

    .tree-focus-card.spouse-card .card-inner {
        width: 75px;
    }

    .tree-focus-card.spouse-card .card-image {
        height: 85px;
    }

    .tree-focus-card.divorced .card-inner {
        width: 70px;
    }

    .tree-focus-card.divorced .card-image {
        height: 80px;
    }

    .tree-focus-couple.has-divorced .divorced-spouse-section {
        padding: 0.4rem 0.5rem;
    }

    .tree-focus-couple.has-divorced .current-spouse-section {
        gap: 0.4rem;
    }

    .tree-marriage-connector .tree-marriage-line,
    .tree-marriage-connector.divorced .tree-marriage-line {
        width: 12px;
    }

    .divorced-label {
        font-size: 0.5rem;
        padding: 0.08rem 0.2rem;
    }

    .tree-child-card .card-inner {
        width: 60px;
    }

    .tree-child-card .card-image {
        height: 60px;
    }

    .tree-parent-card .card-inner {
        width: 70px;
    }

    .tree-parent-card .card-image {
        height: 70px;
    }

    .tree-focus-card .card-name {
        font-size: 0.75rem;
    }

    .tree-focus-card .card-title {
        font-size: 0.6rem;
    }

    .tree-focus-card.spouse-card .card-name {
        font-size: 0.65rem;
    }

    .card-view-btn {
        padding: 0.35rem;
        font-size: 0.6rem;
    }
}

/* Members Grid */
.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.member-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
    border: 1px solid var(--border);
}

.member-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(26, 54, 93, 0.15);
}

.member-card.monarch {
    border-color: var(--accent);
}

.member-image {
    width: 100%;
    height: 220px;
    background-size: cover;
    background-position: center top;
    background-color: #e2e8f0;
}

.member-info {
    padding: 1rem;
}

.member-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.member-card.monarch .member-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.member-card.monarch .member-name::after {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='%23c9a227' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 16L3 5l5.5 5L12 4l3.5 6L21 5l-2 11H5z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.member-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.member-dates {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.member-children {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(44, 82, 130, 0.1);
    border-radius: 10px;
    display: inline-block;
}

/* News Section */
#news-section h2 {
    text-align: center;
    font-size: 2.5rem;
    color: var(--primary-dark);
    margin-bottom: 2rem;
}

.news-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.filter-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.3s ease;
}

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

.filter-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.news-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
    border: 1px solid var(--border);
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(26, 54, 93, 0.15);
}

.news-image {
    height: 180px;
    background-size: cover;
    background-position: center 25%;
    position: relative;
}

.news-tag {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--gradient-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.news-content {
    padding: 1.25rem;
}

.news-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.news-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.news-excerpt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Calendar Section */
#calendar-section h2 {
    text-align: center;
    font-size: 2.5rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.calendar-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.calendar-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--border);
}

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.calendar-nav h3 {
    font-size: 1.5rem;
    color: var(--primary-dark);
}

.calendar-nav-btn {
    background: none;
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: all 0.3s ease;
}

.calendar-nav-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.calendar-grid {
    margin-bottom: 2rem;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.calendar-header span {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.calendar-day:hover {
    background: rgba(44, 82, 130, 0.05);
}

.calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.5;
}

.calendar-day.today {
    background: var(--gradient-primary);
    color: white;
}

.calendar-day.has-event {
    background: rgba(212, 175, 55, 0.15);
    font-weight: 600;
}

.calendar-day.has-event::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 4px var(--accent);
}

/* Fargekoding for kalenderdager */
.calendar-day.has-event-norway::after {
    background: #1a365d;
    box-shadow: 0 0 4px #1a365d;
}

.calendar-day.has-event-uk::after {
    background: #c41e3a;
    box-shadow: 0 0 4px #c41e3a;
}

.calendar-day.has-event-sweden::after {
    background: #006aa7;
    box-shadow: 0 0 4px #006aa7;
}

.calendar-day.has-event-denmark::after {
    background: #c60c30;
    box-shadow: 0 0 4px #c60c30;
}

.calendar-day.has-event-netherlands::after {
    background: #ff6600;
    box-shadow: 0 0 4px #ff6600;
}

.calendar-day.has-event-spain::after {
    background: #c60b1e;
    box-shadow: 0 0 4px #c60b1e;
}

.calendar-day.has-event-monaco::after {
    background: #ce1126;
    box-shadow: 0 0 4px #ce1126;
}

.calendar-day.has-event-belgium::after {
    background: #2d2926;
    box-shadow: 0 0 4px #2d2926;
}

.calendar-day.has-event-multiple::after {
    background: linear-gradient(135deg, #1a365d 50%, #c41e3a 50%);
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* Kalendertegnforklaring */
.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.norway {
    background: #1a365d;
}

.legend-dot.uk {
    background: #c41e3a;
}

.calendar-day.today.has-event {
    background: var(--gradient-primary);
}

.calendar-day.today.has-event::after {
    background: white;
    box-shadow: 0 0 4px white;
}

.events-list {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.events-list h4 {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
}

.event-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    background: var(--gradient-subtle);
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--primary);
}

.event-date-box {
    text-align: center;
    min-width: 50px;
}

.event-date-day {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.event-date-month {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.event-date-time {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 500;
    margin-top: 0.25rem;
}

.event-details h5 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.event-details p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.event-house {
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

/* Fargekoding for kongehus */
.event-item.house-norway {
    border-left-color: #1a365d;
}
.event-item.house-norway .event-date-day {
    color: #1a365d;
}
.event-item.house-norway .event-house {
    background: rgba(26, 54, 93, 0.1);
    color: #1a365d;
}

.event-item.house-uk {
    border-left-color: #c41e3a;
}
.event-item.house-uk .event-date-day {
    color: #c41e3a;
}
.event-item.house-uk .event-house {
    background: rgba(196, 30, 58, 0.1);
    color: #c41e3a;
}

.event-item.house-sweden {
    border-left-color: #006aa7;
}
.event-item.house-sweden .event-date-day {
    color: #006aa7;
}
.event-item.house-sweden .event-house {
    background: rgba(0, 106, 167, 0.1);
    color: #006aa7;
}

.event-item.house-denmark {
    border-left-color: #c60c30;
}
.event-item.house-denmark .event-date-day {
    color: #c60c30;
}
.event-item.house-denmark .event-house {
    background: rgba(198, 12, 48, 0.1);
    color: #c60c30;
}

.event-item.house-netherlands {
    border-left-color: #ff6600;
}
.event-item.house-netherlands .event-date-day {
    color: #ff6600;
}
.event-item.house-netherlands .event-house {
    background: rgba(255, 102, 0, 0.1);
    color: #ff6600;
}

.event-item.house-spain {
    border-left-color: #c60b1e;
}
.event-item.house-spain .event-date-day {
    color: #c60b1e;
}
.event-item.house-spain .event-house {
    background: rgba(198, 11, 30, 0.1);
    color: #c60b1e;
}

.event-item.house-monaco {
    border-left-color: #ce1126;
}
.event-item.house-monaco .event-date-day {
    color: #ce1126;
}
.event-item.house-monaco .event-house {
    background: rgba(206, 17, 38, 0.1);
    color: #ce1126;
}

.event-item.house-belgium {
    border-left-color: #2d2926;
}
.event-item.house-belgium .event-date-day {
    color: #2d2926;
}
.event-item.house-belgium .event-house {
    background: rgba(45, 41, 38, 0.1);
    color: #2d2926;
}

/* Kalenderdager med hendelser fra ulike kongehus */
.calendar-day.has-event-norway::after {
    background: #1a365d;
}
.calendar-day.has-event-uk::after {
    background: #c41e3a;
}
.calendar-day.has-event-multiple::after {
    background: linear-gradient(135deg, #1a365d 50%, #c41e3a 50%);
}

/* Modal */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 54, 93, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 20px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    position: relative;
    animation: slideUp 0.3s ease;
    outline: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* Mobile: sticky close button */
@media (max-width: 768px) {
    .modal-close {
        position: fixed;
        top: 1rem;
        right: 1rem;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    }
}

.modal-body {
    display: flex;
    flex-direction: column;
}

.person-image-large {
    width: 100%;
    height: 320px;
    background-size: cover;
    background-position: center top;
    background-color: #f8f4e8;
    border-radius: 20px 20px 0 0;
}

.person-details {
    padding: 2rem;
}

.person-details h2 {
    font-size: 2rem;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.person-title {
    font-size: 1rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.person-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--gradient-subtle);
    border-radius: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span:last-child {
    font-weight: 500;
    color: var(--text-primary);
}

.person-bio {
    color: var(--text-secondary);
    line-height: 1.8;
}

/* News Modal */
.news-modal-content {
    max-width: 800px;
}

.news-modal-body {
    display: flex;
    flex-direction: column;
}

.news-modal-image {
    width: 100%;
    height: 350px;
    background-size: cover;
    background-position: center;
    background-color: #f8f4e8;
    border-radius: 20px 20px 0 0;
}

.news-modal-details {
    padding: 2rem;
}

.news-modal-tag {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

.news-modal-date {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.news-modal-details h2 {
    font-size: 1.75rem;
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    line-height: 1.3;
}

.news-modal-text {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1.05rem;
    max-height: 400px;
    overflow-y: auto;
}

.news-modal-text p {
    margin-bottom: 1rem;
}

.news-modal-text p:last-child {
    margin-bottom: 0;
}

.news-modal-text img {
    height: 300px;
    object-fit: cover;
    object-position: center 15%;
}

/* News card hover effect */
.news-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(26, 54, 93, 0.15);
}

/* Footer */
.footer {
    background: var(--primary-dark);
    color: white;
    padding: 2rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-logo span {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 600;
}

.logo-small {
    width: 35px;
    height: 30px;
}

.logo-small path,
.logo-small circle {
    fill: white;
}

.footer p {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .header-inner {
        flex-direction: column;
        gap: 0.75rem;
        max-width: 100%;
    }

    .logo-container {
        order: 1;
    }

    .nav {
        order: 2;
        gap: 1.5rem;
    }

    .main-content {
        margin-top: 110px;
    }

    .section {
        padding: 2rem 1rem;
    }

    .hero {
        padding: 2rem 1rem;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .royal-houses-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .house-tabs {
        flex-wrap: wrap;
    }

    .news-filters {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
    }

    .filter-btn {
        flex-shrink: 0;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 0;
        align-items: flex-start;
    }

    .modal-content {
        max-height: 100dvh;
        height: auto;
        min-height: 100dvh;
        border-radius: 0;
        margin: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .person-image-large {
        height: 250px;
        border-radius: 0;
        flex-shrink: 0;
    }

    .person-details {
        padding: 1.5rem;
        padding-top: 1rem;
        padding-bottom: 3rem;
    }

    .person-info {
        grid-template-columns: 1fr;
    }

    .news-modal-content {
        height: auto;
        min-height: 100dvh;
    }

    .news-modal-image {
        height: 200px;
        border-radius: 0;
        flex-shrink: 0;
    }

    .news-modal-details {
        padding-bottom: 3rem;
    }

    .news-modal-details {
        padding: 1.5rem;
    }

    .news-modal-details h2 {
        font-size: 1.35rem;
    }

    .news-modal-text {
        max-height: none;
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
