html {
    scroll-behavior: smooth;
}

body {
    background-color: #f8fafc; /* Fallback */
    background-image: linear-gradient(to bottom, #f8fafc, #eef2f7);
    font-family: 'Inter', sans-serif;
}

.section > .bg-white {
    transition: all 0.3s ease-in-out;
}
.section > .bg-white:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.tab-button {
    transition: all 0.2s ease-in-out;
}
.tab-button.active {
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

a, button {
    transition: all 0.2s ease-in-out;
}

.comparison-card {
    transition: all 0.3s ease-in-out;
}
.comparison-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Section spacing for anchor links to account for fixed header */
.section { scroll-margin-top: 80px; }

/* Base styles for interactive diagram containers */
.interactive-diagram {
    position: relative;
    width: 100%;
    height: 250px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* Smaller height for RFCOMM diagram specifically */
.rfcomm-container {
    min-height: 200px; /* Reduced height for this specific diagram */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rfcomm-link {
    position: absolute;
    left: 30%;
    width: 40%;
    height: 3px;
    background-color: #7dd3fc;
    z-index: 1;
}

.rfcomm-stack {
    height: 80px;
    width: 100px;
    background-color: #f0f9ff;
    border: 2px solid #0284c7;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px;
    z-index: 5;
}

.rfcomm-buffer {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    font-weight: bold;
    color: #0369a1;
    margin-top: auto;
    background-color: #e0f2fe;
    width: 100%;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Tooltip system for interactive elements */
[data-tooltip] {
    position: relative;
    cursor: pointer;
}
[data-tooltip]:before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    background-color: #111827;
    color: #ffffff;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 20;
    font-size: 0.875rem;
}
[data-tooltip]:hover:before { opacity: 1; visibility: visible; }

/* Animation keyframes for various interactive elements */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

/* Heartbeat animation for data streams */
@keyframes data-heartbeat {
    0% { background-color: #16a34a; transform: scaleX(1); }
    50% { background-color: #34d399; transform: scaleX(1.05); }
    100% { background-color: #16a34a; transform: scaleX(1); }
}

/* Horizontal scanning animation for BLE scanner */
@keyframes scanner-sweep-horizontal {
    0% { left: calc(10% + 48px); }
    100% { left: calc(90% - 48px); }
}

/* Table styling for comparison sections */
.comparison-table td, .comparison-table th {
    padding: 1rem;
    border: 1px solid #e5e7eb;
}

/* Timeline component styling for Bluetooth version history */
.timeline-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    cursor: pointer;
    list-style: none; /* Hide the default marker */
}

.timeline-summary::-webkit-details-marker {
    display: none; /* Hide the default marker in Chrome/Safari */
}

.timeline-arrow {
    flex-shrink: 0;
    width: 0.8rem;
    height: 0.8rem;
    border-right: 3px solid #9ca3af;
    border-bottom: 3px solid #9ca3af;
    transform: rotate(45deg);
    transition: transform 0.2s ease-in-out;
}

.timeline-group[open] > .timeline-summary > .timeline-arrow {
    transform: rotate(225deg);
}

.timeline-content {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.timeline-item {
    position: relative;
    padding-bottom: 1rem;
    padding-left: 2rem;
    border-left: 2px solid #d1d5db;
}

.timeline-item:last-child {
    padding-bottom: 0;
    border-left-color: transparent;
}

.timeline-dot {
    position: absolute;
    left: -0.5rem; top: 0;
    height: 1rem; width: 1rem;
    border-radius: 9999px;
    background-color: white;
    border: 4px solid #9ca3af;
}

/* Device icon styling used throughout diagrams */
.device-icon {
    width: 48px; height: 48px;
    filter: drop-shadow(0 4px 3px rgba(0,0,0,0.1));
    transition: transform 0.3s ease;
}

/* Auracast source selection styling */
.auracast-source {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 4px solid transparent;
    border-radius: 9999px;
}
.auracast-source:hover .device-icon { transform: scale(1.1); }
.auracast-source.selected {
    border-color: #fbbf24;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.7);
}

/* Large emoji icons for deep dive section */
.deep-dive-icon {
    font-size: 2.5rem;
    line-height: 1;
}

/* Styles for the Classic Connection Roles and Piconet */
.role-label {
    position: absolute;
    top: calc(50% + 30px);
    transform: translateX(-50%);
    font-weight: bold;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: #ede9fe;
}
.role-master .device-icon {
    color: #8b5cf6;
}
.role-slave .device-icon {
    color: #6b7280;
}
.piconet-link {
    position: absolute;
    left: calc(10% + 48px);
    top: 50%;
    width: calc(80% - 96px);
    height: 2px;
    background-image: linear-gradient(to right, #a78bfa 50%, transparent 50%);
    background-size: 10px 2px;
}

/* Style for the active navigation link */
header a.active-nav {
    color: #2563eb; /* blue-600 */
    font-weight: 700;
}

.nav-link {
    color: #4b5563; /* text-gray-600 */
    transition: color 0.2s ease-in-out;
}
.nav-link:hover {
    color: #3b82f6; /* hover:text-blue-500 */
}

/* Mobile Sidebar Styles */
@media (max-width: 767px) {
    #mobile-menu {
        @apply fixed top-0 left-0 h-full w-64 bg-white shadow-xl z-30 transform -translate-x-full transition-transform duration-300 ease-in-out;
        @apply flex flex-col space-x-0 space-y-1 p-8;
    }
    #mobile-menu.open {
        @apply -translate-x-0;
    }
    .nav-link {
        display: block;
        font-size: 1.125rem; /* text-lg */
        padding: 1rem; /* p-4 */
        border-radius: 0.375rem; /* rounded-md */
    }
    header a.active-nav {
        background-color: #eff6ff; /* bg-blue-50 */
    }
}

/* Styles for fade-in-on-scroll animation */
.fade-in-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.fade-in-section.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Styles for the GATT Hierarchy diagram */
.gatt-container {
    height: auto;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
}
.gatt-client {
    border: 2px solid #1d4ed8;
    background-color: #eef2ff;
    padding: 1.5rem;
    padding-top: 3rem;
    border-radius: 0.75rem;
    position: relative;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.gatt-client::before {
    content: 'GATT Client';
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    color: #1e40af;
    font-size: 0.8rem;
}
.gatt-server {
    border: 2px solid #059669;
    background-color: #f0fdf4;
    padding: 1rem;
    padding-top: 2.5rem;
    border-radius: 0.75rem;
    position: relative;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}
.gatt-services-container {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}
.gatt-server::before {
    content: 'GATT Server';
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    color: #047857;
    font-size: 0.8rem;
    background-color: #ffffff;
}
.gatt-service {
    border: 2px solid #0d9488;
    background-color: #ccfbf1;
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.gatt-char {
    border: 1px dashed #6b7280;
    background-color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    margin-top: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
#heart-rate-value, #location-value {
    width: 160px;
}
.gatt-char:hover {
    border-color: #0d9488;
    background-color: #f0fdfa;
}
.gatt-char > div:last-child {
    min-width: 150px;
}
.gatt-packet {
    position: absolute;
    padding: 4px 8px;
    border-radius: 6px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    transition: all 0.8s ease-in-out;
    opacity: 0;
    z-index: 10;
}

/* General packet styling for EATT demo */
.packet {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    transition: all 1.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Styles for the Security diagram */
.security-container {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.security-packet {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    transition: all 1s ease-in-out;
    opacity: 0;
    padding: 6px 10px;
    border-radius: 6px;
    color: white;
}
.security-key {
    position: absolute;
    top: 25%;
    font-size: 2rem;
    transition: all 0.5s ease-in-out;
    opacity: 0;
}
.storage-box {
    margin-top: 0.5rem;
    height: 32px;
    width: 32px;
    border: 2px dashed #9ca3af;
    border-radius: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease-in-out;
    color: #64748b;
    font-size: 1.2rem;
}
.storage-box.bonded {
    border-style: solid;
    border-color: #16a34a; /* green-600 */
    background-color: #dcfce7; /* green-100 */
}

.interference-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #fca5a5; /* red-300 */
    border-radius: 50%;
    animation: flicker 1.5s infinite alternate ease-in-out;
}

@keyframes flicker {
    from { opacity: 0.2; transform: scale(0.8); }
    to { opacity: 0.7; transform: scale(1.1); }
}

/* Basic responsive layout adjustments */
@media (max-width: 768px) {
    .comparison-card {
        min-height: 250px; /* Ensure cards have a decent height on mobile */
    }
}

/* Styling for the codec comparison table */
.codec-table th {
    background-color: #f3f4f6; /* gray-100 */
    border-bottom: 2px solid #e5e7eb; /* gray-200 */
}
.codec-table td {
    border-bottom: 1px solid #e5e7eb; /* gray-200 */
}
.codec-table tbody tr:last-child td {
    border-bottom: none;
}
.codec-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

/* Styling for the codec rating bars */
.rating-container {
    display: flex;
    gap: 4px;
    justify-content: center;
    min-width: 120px; /* Ensure container has a minimum width */
}
.rating-bar {
    width: 100%;
    height: 1rem;
    background-color: #e5e7eb; /* gray-200 */
    border-radius: 2px;
}
.rating-bar.quality.filled {
    background-color: #0ea5e9; /* sky-500 */
}
.rating-bar.latency.filled {
    background-color: #a855f7; /* purple-500 */
}
.rating-bar.power.filled {
    background-color: #14b8a6; /* teal-500 */
}

/* Styling for the codec table dropdowns */
.codec-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.codec-row:hover {
    background-color: #f8fafc; /* slate-50 */
}
.codec-details-row td {
    background-color: #f1f5f9; /* slate-100 */
    padding: 0;
}
.codec-details-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease-out, padding 0.35s ease-out;
    padding: 0 1rem;
}
.codec-details-row.is-open .codec-details-content {
    max-height: 20rem; /* Animate to this height */
    padding: 1rem;
    transition: max-height 0.4s ease-in, padding 0.4s ease-in;
}
.codec-toggle-btn {
    font-family: monospace;
    font-size: 1.25rem;
    line-height: 1;
    color: #94a3b8; /* slate-400 */
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    transition: transform 0.2s ease-in-out;
}
.codec-toggle-btn:hover {
    color: #334155; /* slate-700 */
}
.codec-toggle-btn.is-open {
    transform: rotate(180deg);
}

/* Responsive Codec Table */
@media (max-width: 768px) {
    .codec-table thead {
        display: none;
    }
    .codec-table, .codec-table tbody, .codec-table tr, .codec-table td {
        display: block;
        width: 100%;
    }
    .codec-table tr {
        margin-bottom: 1rem;
    }
    .codec-table .codec-row {
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        overflow: hidden;
    }
    .codec-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #e5e7eb;
    }
    .codec-table td:last-child {
        border-bottom: none;
    }
    .codec-table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        margin-right: 1rem;
    }
    .codec-table .rating-container {
        justify-content: flex-end;
    }
    .codec-details-row.is-open .codec-details-content {
        padding: 1rem;
    }
    .codec-details-content {
        background-color: #f8fafc; /* gray-50 */
    }
}

/* Styles for the Profile Cards section */
.profile-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.75rem; /* rounded-xl */
    background-color: #f9fafb; /* gray-50 */
    transition: all 0.2s ease-in-out;
}
.profile-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.07);
    border-color: #d1d5db; /* gray-300 */
}
.profile-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem; /* w-14 */
    height: 3.5rem; /* h-14 */
    border-radius: 0.5rem; /* rounded-lg */
}

/* Styles for the PHY selection buttons and diagram */
.phy-button {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.875rem;
    border: 2px solid #d1d5db; /* gray-300 */
    background-color: #f9fafb; /* gray-50 */
    transition: all 0.2s ease-in-out;
}
.phy-button:hover {
    background-color: #f3f4f6; /* gray-200 */
    border-color: #9ca3af; /* gray-400 */
}
.phy-button.active {
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
#phy-info .phy-stat {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    width: 100%;
}
#phy-info .phy-stat-label {
    width: 5rem;
    text-align: right;
    flex-shrink: 0;
}
#phy-info .phy-stat-bar-container {
    flex-grow: 1;
    height: 1.25rem;
    background-color: #e5e7eb;
    border-radius: 0.25rem;
    overflow: hidden;
}
#phy-info .phy-stat-bar {
    height: 100%;
    background-color: #3b82f6; /* blue-500 */
    border-radius: 0.25rem;
    transition: width 0.4s ease-in-out;
}

/* Styles for CIS/BIS stream animations */
.stream-packet {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 4px;
    opacity: 0;
    transition: all 1.5s linear;
} 