/* Optional overrides for badge display */
.badge-grid img { width: 120px; margin: 5px; }

/* Sidebar avatar */
.sidebar-about {
	position: relative;
	overflow: visible;
	padding-bottom: 8px; /* give small breathing room under the avatar/title */
}

/* larger avatar, scaled image and overlayed title */
.sidebar-avatar {
	width: 280px;
	height: 280px;
	border-radius: 6px;
	background: #222;
	overflow: visible; /* allow scaled image to show outside the box */
	margin-bottom: 0; /* title will overlap here */
	box-shadow: 0 2px 10px rgba(0,0,0,0.38);
	position: relative;
}

.sidebar-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	position: relative;
	transform: scale(1.45); /* increase scale so image appears larger */
	transform-origin: center center;
	left: -6%; /* nudge left so scaled image centers visually */
}

/* stronger gradient fade at the bottom to improve title contrast and cover enlarged area */
.sidebar-avatar::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 120%; /* extend slightly to cover scaled edges */
	height: 70%;
	transform: translateX(-10%);
	pointer-events: none;
	background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 30%, rgba(0,0,0,0.75) 60%, rgba(34,34,34,1) 100%);
}

/* overlay the site title on the lower part of the avatar */
.sidebar-title {
	position: absolute;
	left: 12px;
	bottom: 18px;
	z-index: 4;
	color: #fff;
	font-size: 2.6rem;
	line-height: 1;
	margin: 0;
	padding: 4px 8px; /* small padding for legibility */
	text-shadow: 0 4px 10px rgba(0,0,0,0.6);
	pointer-events: none; /* clicks pass through to links underneath */
}

/* move the lead description slightly below the avatar/title area so it doesn't overlap */
.sidebar-about .lead {
	margin-top: calc(280px * 0.32); /* nudge down based on avatar height */
	color: #d2d2d2;
}

/* Make the sidebar immersed in the profile photo */
.sidebar.photo {
	background-repeat: no-repeat;
	/* use auto width to avoid aggressive cropping/zoom on wide viewports */
	background-size: auto 100%;
	background-position: center center;
	color: #fff; /* default text color on photo */
	position: relative;
}

/* dark overlay so text is legible */
.sidebar.photo::before {
	content: "";
	position: absolute;
	inset: 0;
	/* slightly softened overlay so the image shows without losing contrast */
	background: linear-gradient(180deg, rgba(0,0,0,0.48) 12%, rgba(0,0,0,0.6) 40%, rgba(0,0,0,0.8) 100%);
	z-index: 0;
}

/* place container content above overlay */
.sidebar.photo .container {
	position: relative;
	z-index: 2;
}

/* style adjustments for readability when image is the background */
.sidebar.photo .sidebar-about h1,
.sidebar.photo .sidebar-about .lead,
.sidebar.photo .sidebar-nav a,
.sidebar.photo p {
	color: #fff;
}

/* Social Links */
.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    margin-left: -0.5rem;
}

.social-link {
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.3s ease, transform 0.2s ease;
}

.social-link:hover {
    color: #fff;
    transform: scale(1.1);
    text-decoration: none;
}

.social-link svg {
    width: 24px;
    height: 24px;
}

/* Notes Tree Styling */
.notes-section {
    margin-top: 1rem;
    margin-left: -0.5rem;
}

.notes-header, .category-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /*padding: 0.25rem 0;*/
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.3s ease;
}

.notes-header:hover, .category-header:hover {
    color: #fff;
}

.notes-tree {
    display: none;
    margin-left: 1.25rem;
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

.notes-section.active .notes-tree {
    display: block;
}

.note-category {
    margin: 0.5rem 0;
}

.category-items {
    display: none;
    margin-left: 0.4rem;
}

.note-category.active .category-items {
    display: block;
}

.note-item {
    display: block;
    padding: 0.25rem 0;
    padding-left: 1.0rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.3s ease;
}

.note-item:hover {
    color: #fff;
    text-decoration: none;
}

.note-item.active {
    color: #fff;
    font-weight: 600;
}

.fa-chevron-right {
    transition: transform 0.3s ease;
}

.notes-header .fa-chevron-right,
.category-header .fa-chevron-right {
    font-size: 0.75rem;
}

.notes-section.active > .notes-header .fa-chevron-right,
.note-category.active > .category-header .fa-chevron-right {
    transform: rotate(90deg);
}

.category-items .note-category {
    margin: 0.35rem 0;
}

.category-items .note-category .category-header {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.category-items .note-category.active > .category-header {
    color: #fff;
}

.category-items .note-category .category-items {
    margin-left: 0.75rem;
}

.note-empty {
    margin: 0.5rem 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar.photo .sidebar-nav a {
    display: block;
    color: rgba(255,255,255,0.92);
    text-align: left;
    padding: 0.25rem 0;
}

.sidebar.photo .sidebar-nav a:hover {
	color: #fff;
}

/* make footer/p copyright slightly dimmer */
.sidebar.photo p { color: rgba(255,255,255,0.75); }

/* Desktop tweak: slightly larger background width for narrow sidebars on large screens */
@media (min-width: 1100px) {
	.sidebar.photo {
		/* allow a bit more horizontal coverage on very large viewports without extreme zoom */
		background-size: auto 115%;
		background-position: 45% 12%;
	}
}

/* Phone optimizations */
@media (max-width: 700px) {
    .sidebar-hero {
        height: 100vh;
        background-position: center 20%;
    }
    
    .sidebar-about h1 {
        font-size: 2.2rem;
    }
    
    .sidebar-about .lead {
        font-size: 1rem;
        opacity: 0.9;
    }
    
    .sidebar-nav {
        margin-top: 1.5rem;
    }
    
    .sidebar-nav-item {
        padding: 0.4rem 0;
        text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    }
}

/* Defensive: hide any leftover avatar IMG elements if they still exist in built files */
.sidebar .sidebar-avatar,
.sidebar .sidebar-avatar img,
.sidebar > img {
  display: none !important;
}

/* Full-height hero with gradient overlay */
.sidebar-hero {
    height: 100vh;
    width: 100%;
    position: relative;
    background-image: url('/assets/images/profile.png');
    background-size: contain;
    background-position: center center;
}

/* Smooth, subtle gradient overlay for text readability */
.sidebar-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 75%;
    background: linear-gradient(to bottom, 
        rgba(0,0,0,0) 0%,
        rgba(0,0,0,0.1) 20%,
        rgba(0,0,0,0.2) 40%,
        rgba(0,0,0,0.3) 60%,
        rgba(0,0,0,0.4) 80%,
        rgba(0,0,0,0.45) 100%);
    pointer-events: none;
}

.sidebar-panel {
    position: relative;
	height: auto;
    bottom: 0;
    left: 0;
    right: 0;
    background: transparent;
    padding: 2rem;
    color: #fff;
    z-index: 2;
}

.sidebar-about h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin: 0;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.sidebar-about .lead {
    font-size: 1.4rem;
    margin-top: 0.5rem;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Make sure the sticky container doesn't cover the hero rounded corners on small viewports */
@media (max-width: 800px) {
    .sidebar-hero { 
        height: 240px;
        margin-bottom: 20px;
    }
    .sidebar-panel {
        margin-top: 0;
        padding: 20px;
        background: rgba(26,26,26,0.95);
    }
    .sidebar-about h1 {
        font-size: 2rem;
        line-height: 1.1;
        margin-bottom: 0.5rem;
    }
    .sidebar-about .lead {
        font-size: 1rem;
        margin-top: 0.5rem;
    }
}

/* Smallest phones */
@media (max-width: 380px) {
    .sidebar-hero {
        height: 200px;
        margin-bottom: 16px;
    }
    .sidebar-about h1 {
        font-size: 1.8rem;
    }
}

/* --- Sidebar Alignment, Font, and Scrolling Fixes --- */
.sidebar-panel {
    position: relative;
    height: auto;
    overflow: visible;
    padding: 2rem;
    color: #fff;
    z-index: 2;
    background: transparent;
}

@media (min-width: 48em) {
    .sidebar-panel {
        height: 100vh;
        overflow-y: auto;
    }
}

.sidebar-nav,
.notes-section,
.note-category,
.category-items {
    text-align: left;
}

.sidebar-nav-item,
.notes-header,
.category-header,
.note-item {
    font-size: 1.00 rem;
    font-weight: 500;
    margin-left: 0;
    padding-left: 0;
    line-height: 1.6;
}

.notes-header,
.category-header {
   /* margin-top: 1rem;*/
    display: flex;
    align-items: center;
    font-weight: 500; /* Remove bold, match main links */
}

.category-items .note-item {
    margin-left: 1rem; /* Reduced from 2rem to 1rem for tighter indentation */
    font-size: 0.8rem;
    font-weight: 400;
}

.notes-tree {
    margin-left: 0.8rem;
}

.sidebar-nav-item {
    margin: 0.5rem 0;
}

@media (max-width: 700px) {
    .sidebar-panel {
        padding: 1rem;
    }
    .sidebar-nav-item,
    .notes-header,
    .category-header,
    .note-item {
        font-size: 1rem;
    }
}
/* --- End Sidebar Fixes --- */

/* Screen reader helper */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mobile-menu-toggle,
.mobile-menu-overlay {
    display: none;
}

@media (max-width: 48em) {
    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 1rem);
        right: calc(env(safe-area-inset-right, 0px) + 1rem);
        width: 3rem;
        height: 3rem;
        border: none;
        border-radius: 0.5rem;
        background: rgba(21, 21, 21, 0.92);
        color: #fff;
        cursor: pointer;
        z-index: 1100;
        transition: background 0.3s ease, transform 0.3s ease;
    }

    .mobile-menu-toggle:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.65);
        outline-offset: 3px;
    }

    .mobile-menu-toggle .mobile-menu-bar {
        display: block;
        width: 22px;
        height: 2px;
        background: currentColor;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .mobile-menu-toggle .mobile-menu-bar + .mobile-menu-bar {
        margin-top: 6px;
    }

    body.sidebar-open .mobile-menu-toggle {
        background: rgba(21, 21, 21, 0.75);
    }

    body.sidebar-open .mobile-menu-toggle .mobile-menu-bar:nth-of-type(1) {
        transform: translateY(8px) rotate(45deg);
    }

    body.sidebar-open .mobile-menu-toggle .mobile-menu-bar:nth-of-type(2) {
        opacity: 0;
    }

    body.sidebar-open .mobile-menu-toggle .mobile-menu-bar:nth-of-type(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .mobile-menu-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 900;
    }

    body.sidebar-open .mobile-menu-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    body .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(320px, 82vw);
        transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
        box-shadow: 0 0 26px rgba(0, 0, 0, 0.45);
        z-index: 1001;
        background: rgba(21, 21, 21, 0.97);
    }

    body:not(.sidebar-open) .sidebar {
        transform: translateX(-105%);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body .sidebar-panel {
        height: 100%;
        overflow-y: auto;
        padding: calc(env(safe-area-inset-top, 0px) + 4.5rem) 1.75rem calc(env(safe-area-inset-bottom, 0px) + 2.75rem);
        background: rgba(26, 26, 26, 0.95);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body .content.container {
        padding: 2.5rem 1.5rem calc(env(safe-area-inset-bottom, 0px) + 4rem);
    }
}
